27

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!

2

2 Answers 2

38

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

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

4
  • :unmap <Tab> doesn't do the trick.. for some reason :/
    – Grigor
    Jun 22, 2013 at 21:54
  • this works for me.
    – doubleDown
    Jun 23, 2013 at 1:20
  • 8
    @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, 2013 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, 2018 at 14:12
0

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.

1
  • 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. Sep 4, 2015 at 7:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .