vimconfigurationsupertab

How can I insert a real tab character in Vim?


When I have my vimrc here:

set tabstop=2
set shiftwidth=2
set softtabstop=2
set expandtab
set smarttab

And I have supertab plugin installed. Whenever I am in insert mode I press tab, it shows the auto completion, but sometimes I would like to insert a real tab character in a string literal like. So what I mean whenever I press tab in double quotes string literal, it should input we a real tab character.


Solution

  • While in insert mode or command mode (the : prompt at the bottom of the editor), type CTRL + V then TAB.

    Using CTRL + V signals Vim that it should take the next character literally. Even in insert mode.

    UPDATE:

    As noted by Herbert Sitz, if gVim is in Windows mode (default), you must use CRTL + Q in place of CTRL + V.