Search code examples
vim

Map shift-tab in vim to inverse tab in Vim


I've done some searching and found a wealth of information on binding keys in vim, but I can't find out, for sure, how to map shift-tab. Or what command I need to map it to for it to "tab backwards".

This is what I have at the moment:

map <S-tab> <S-,><S-,>

Possibly Relevant Information: I'm running Debian with Terminal 2.22.3. with VIM - Vi IMproved 7.1


Solution

  • Vim already has built-in key commands for insert mode to shift the current line left or right one &shiftwidth. They are (in insert mode):

    Ctrl-t : shift right (mnemonic "tab")

    Ctrl-d : shift left (mnemonic "de-tab")

    If you still want to use shift-tab, this is how you do it:

    " For command/normal mode
    nnoremap <S-Tab> <<
    " For insert mode
    inoremap <S-Tab> <C-d>