Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A confusion about shortcut key of youcompleteme for vim

Tags:

vim

all. I am trying to use youcompleteme for code completing in vim. Generally, it works well except that when i need to jump between source files. First. I use the subcommand

:YcmCompleter GoToDefinition

it can find the definition. BUT it seems so verbose. Then I want to map this subcommand into some shortcut key according to the YCM's instruction:

nnoremap <leader>gl :YcmCompleter GoToDeclaration<CR>
nnoremap <leader>gf :YcmCompleter GoToDefinition<CR>
nnoremap <leader>gg :YcmCompleter GoToDefinitionElseDeclaration<CR>

I am a little confused. what is short cut key? l or gl ?

like image 542
Donghui Sun Avatar asked Apr 11 '15 03:04

Donghui Sun


People also ask

What is Vim YouCompleteMe?

< Vim. YouCompleteMe (shortened as YCM) is a code-completion engine for Vim. It supports the following languages: C/C++/Objective-C/Objective-C++ Python.

How do I install YouCompleteMe?

Install the prerequisite Termux packages. Install Vundle by following the official instructions. This includes cloning the repository and editing your vimrc as necessary. Install YouCompleteMe by adding it to the list of plugins in your vimrc file, and then running the :PluginInstall command in vim.


1 Answers

When you create a mapping with <leader>, <leader> is replaced by whatever is in your "mapleader" variable (by default \).

If you have this in your vimrc:

let mapleader=","
nnoremap <leader>gl :YcmCompleter GoToDeclaration<CR>

It acts the same as:

nnoremap ,gl :YcmCompleter GoToDeclaration<CR>

Thus you could run the YcmCompleter GoToDeclaration command by pressing ,gl

like image 95
Daan Bakker Avatar answered Nov 17 '22 12:11

Daan Bakker