So I was looking for a way of indenting multiple lines in vim and someone suggested doing

:map <Tab> <

and all it does is insert the < character whenever I press tab (How did I not see it happen). I tried to do :map <Tab> <Tab> and :map <Tab> \t to bring back regular indenting, with no success. I am new to vim key mapping so I would really appreciate help. Also if someone could point out how to indent multiple lines in vim, that would be awesome.

Thanks in advance!


:unmap <Tab> to get the default behavior back.

use :x>> to indent x number of lines (from where the cursor is)

  • :unmap <Tab> doesn't do the trick.. for some reason :/ – Grigor Jun 22 '13 at 21:54
  • this works for me. – doubleDown Jun 23 '13 at 1:20
  • 6
    @Grigor In your question you claimed that you used map <Tab> <. To undo this correct command is indeed unmap <Tab>, but the next text (“all it does is insert the < character”) means that original claim is false. There is no way you could insert < with such mapping, but it would be true if you have written imap <Tab> <. This command is undone using iunmap <Tab> (note the i in both commands). To get correct answers you must be precise. – ZyX Jun 23 '13 at 18:22
  • 1
    A note in case someone had the same struggle as me, if the original mapping is buffer local, then the unmapping must be also: iunmap <buffer> <Tab> – cristoper Oct 10 '18 at 14:12

This solved the issue to revert back tabbing.

:imap <Tab> <C-t>
:imap <S-Tab> <C-d>

Pressing Tab indents the code, Shift-Tab reverts indentation the code.

  • 4
    you can also use :iunmap <Tab>. If <Tab> is mapped by :imap, you have to use :iunmap to unmap it. :unmap <Tab> doesn't work in this case. – Hai Feng Kao Sep 4 '15 at 7:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.