-1

Sometimes I need to press TAB, but instead of getting actual the tab key, a suggestion pops up and TAB cycles through the suggestions.

How can I insert TAB without invoking the auto-completion ?

The problem occurrs both in YouCompleteMe and SuperTab plugins.

1

I would just use a different key mapping for completion instead of hijacking the Tab key. Having one key to preform two actions and "guess" which one it should do is just a misguided approach IMHO.

For SuperTab see :help supertab-forwardbackward:

g:SuperTabMappingForward  (default value: '<tab>')
g:SuperTabMappingBackward (default value: '<s-tab>')

These two variables allow you to set the keys used to kick off the current
completion. By default this is <tab> and <s-tab>. To change to something
like <c-space> and <s-c-space>, you can add the following to your |vimrc|.

    let g:SuperTabMappingForward = '<c-space>'
    let g:SuperTabMappingBackward = '<s-c-space>'

And for YouCompleteMe see :help g:ycm_key_list_select_completion:

The *g:ycm_key_list_select_completion* option

This option controls the key mappings used to select the first completion
string. Invoking any of them repeatedly cycles forward through the completion
list.

Some users like adding '<Enter>' to this list.

Default: "['<TAB>', '<Down>']"

    let g:ycm_key_list_select_completion = ['<TAB>', '<Down>']

Another alternative is mapping another key combination to <Tab>; e.g.:

inorenap <Leader><Tab> <Tab>

And then use \<Tab> to get the default tab behaviour.

2

You can always bypass the effects of a keypress by preceding it with a ctrl-v. For example, if you'd like to insert a literal escape character without returning to normal mode, you can do from insert mode:

<C-v><esc>

This also works on the command line. I don't have YouCompleteMe, or SuperTab installed so I haven't tested this solution, but it should work fine to do

<C-v><tab>

Let me know if this works for you!

  • I have SuperTab installed, and <c-v><tab> works. – muru Dec 5 '16 at 4:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.