Un-mapping commands in Vim

16

3

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!

Grigor

Posted 2013-06-22T21:42:28.900

Reputation: 263

1:unmap http://vim.wikia.com/wiki/Mapping_keys_in_Vim_-_Tutorial_(Part_1) Google is your friend. – Adam Liss – 2013-06-22T21:49:05.083

1@AdamLiss Google has been my friend, my friend, for so long. – Grigor – 2013-06-22T21:56:11.833

Answers

25

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

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

ennuikiller

Posted 2013-06-22T21:42:28.900

Reputation: 980

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 – 2018-10-10T14:12:55.787

:unmap <Tab> doesn't do the trick.. for some reason :/ – Grigor – 2013-06-22T21:54:53.970

this works for me. – doubleDown – 2013-06-23T01:20:50.460

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 – 2013-06-23T18:22:33.547

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.

Grigor

Posted 2013-06-22T21:42:28.900

Reputation: 263

3you 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 – 2015-09-04T07:54:10.233