diff --git a/README.md b/README.md index 47e72530..c554ad49 100644 --- a/README.md +++ b/README.md @@ -782,10 +782,11 @@ after typing `.`, `->` and `::` in insert mode (if semantic completion support has been compiled in). This key mapping can be used to trigger semantic completion anywhere. Useful for searching for top-level functions and classes. -Note that the default of `` means Ctrl-Space. Also note that the -default mapping will probably only work in GUI Vim (Gvim or MacVim) and not in -plain console Vim because the terminal usually does not forward modifier key -combinations to Vim. +Console Vim (not Gvim or MacVim) passes `` to Vim when the user types +`` so YCM will make sure that `` is used in the map command when +you're editing in console Vim, and `` in GUI Vim. This means that you +can just press `` in both console and GUI Vim and YCM will do the right +thing. Setting this option to an empty string will make sure no mapping is created. diff --git a/autoload/youcompleteme.vim b/autoload/youcompleteme.vim index a5780104..69c5ce44 100644 --- a/autoload/youcompleteme.vim +++ b/autoload/youcompleteme.vim @@ -119,10 +119,16 @@ function! s:SetUpKeyMappings() endfor if !empty( g:ycm_key_invoke_completion ) + let invoke_key = g:ycm_key_invoke_completion + + " Inside the console, is passed as to Vim + if invoke_key ==# '' && !has('gui_running') + let invoke_key = '' + endif + " trigger omni completion, deselects the first completion " candidate that vim selects by default - silent! exe 'inoremap ' . g:ycm_key_invoke_completion . - \ ' ' + silent! exe 'inoremap ' . invoke_key . ' ' endif if !empty( g:ycm_key_detailed_diagnostics )