How can i insert a tab after choosing a proposed completion in vim

0

I thought I knew the answer to this.

I used to do <C-V> tab as suggested in "How to insert a real tab with Vim SuperTab plugin if completion fails" and many others.

If i set list though, I can see that I get an actual tab instead of my four spaces (with expandtab set) and that really messes up my code.

Is there a way to:

  1. write
  2. chooses some suggested autocompletion
  3. insert tab (as defined with expandtab)

evading

Posted 2015-01-12T13:52:08.137

Reputation: 105

Answers

1

  • SuperTab has a fallback; Ctrl + Tab by default. See :help g:SuperTabMappingTabLiteral. I think pressing this should suffice. (You can also change the config to use another key, or :inoremap <F1> <Tab> yourself).
  • You can conclude the completion with Ctrl + Y (cp. :help complete_CTRL-Y); this closes the popup menu and therefore the special handling of <Tab>.
  • If all that doesn't help, try concluding the completion by pressing Space, followed by Tab. The former avoids that SuperTab is triggered again, and the latter will expand the whitespace to the next tabstop value, and format it according to your indent settings.

Ingo Karkat

Posted 2015-01-12T13:52:08.137

Reputation: 19 513

Using Space and then Tab was just what I wanted to avoid since it could mean that your first space brings you to a tab-stop and the following tab takes you one more forward. CRTL-Y or CTRL_SPACE works fine though, thanks. – evading – 2015-01-14T13:03:57.150