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
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 mode
nnoremap <S-Tab> <<
" for insert mode
inoremap <S-Tab> <C-d>
Works like a charm. Thank you so much for your help. This will really improve my efficiency. This has really made my day. Thanks again. :)
And for those of you who (like me) aren't smart enough to set shiftwidth when you changed tabstop, running 'set shiftwidth=##', preferably whatever tabstop is
Also worth mentioning that this can be combined with Ctrl and other control keys like
<S-C-Tab>
Hi amphetamachine. I added this into my
.vimrc
on my Mac OS X, however, it doesn't seem it works when I use Shift+Tab.Sorry to revive an old post - but it would be a good idea to use "vim -w" or "vim -W" to log keys (vim -w output_log (...) to append to output_log, or vim -W output_log (...) to overwrite it) so you can verify that a parent container isn't intercepting the shift-tab. If, say, tab is logged but shift-tab isn't, try checking your shell key mappings, then maybe your terminal emulator, desktop environment, etc. Finally you can try the approach here, which should let you hide inputs from the terminal during vim sessions: vim.wikia.com/wiki/Map_Ctrl-S_to_save_current_or_new_files