4
2
I'm trying to set up some basic configuration for vim to make it more useful for myself. One of the things I'm trying to do is map shift+tab to a literal tab character, since my vim configuration sets tabs to be expanded with spaces by default. I attempted to map to the tab char using this reference but no dice.
When I try to strike shift+tab whilst insert mode is active, vim outputs a capital Z for about one second, then removes it and drops out of insert mode with a system error beep. I already tested the shift+tab stroke with ^V and it output ^[[Z into vim as described in the reference, so it's not my OS hijacking the keystroke. Not exactly sure what's causing this; input would be appreciated.
My .vimrc:
" Few basic settings first; I like syntax highlighting & line numbers
syntax on
set number
" Some settings with the list option
" I like to see non-printing characters like Tab & CR
set listchars=tab:▸\ ,eol:¬
set list
" Set tab behaviours: 4 spaces wide, expand <Tab> and >> with spaces
set expandtab
set tabstop=4
set softtabstop=4
set shiftwidth=4
" This line maps shift+tab to a literal tab character
" Because I sometimes need a literal tab
set <s-tab>=
The very last line shows the ▸ character in vim when set list
is on
Just tried it and it still didn't work. :( shift+tab expanded into four spaces instead. – Calyo Delphi – 11 years ago
For the
noremap
command, did you type it exactly as it appears? Because you're meant to. Also, what's output of ":verbose set expandtab?
", with the question mark as part of the command. – Heptite – 11 years agoAlso, are you trying to insert a tab into the file, or are you trying to change
<S-Tab>
to behave like<Tab>
in Vim. The answer matters. If the latter, change:noremap
to just:map
. – Heptite – 11 years agoI'm trying to change <S-Tab> so that it inserts a literal tab character into the file. <Tab> behaves as expected and indents the text with spaces. – Calyo Delphi – 11 years ago
Sorry it took me a while to understand what you needed. Yeah, you probably still need to set
t_tB
, but the mapping you need is::inoremap <S-Tab> <C-V><Tab>
– Heptite – 11 years agoYES! Thank you so very much! :D That's exactly what I needed and it works perfectly! – Calyo Delphi – 11 years ago