5

This is probably an easy question for most vim users.

I want to map :tabn to <C-Tab>. It works perfectly while I'm in normal mode but when I'm in my insert mode (typing code) it just inserts tabs characters.

In my vimrc file I have

map <C-Tab> :tabn<CR>

Any ideas? Thanks!

8

Try this:

:imap <C-Tab> <Esc>:tabn<CR>

That will leave you in normal mode after switching to the next tab. You could instead use this:

:imap <C-Tab> <C-O>:tabn<CR>

which will put you back into insert mode in the next tab at the position where you left the cursor in that tab.

0

You will need to use the imap command. You will also need to prepend <ESC> to it to make it leave insert mode first.

imap <C-Tab> <ESC>:tabn<CR>
2
  • When I did that it just inserted :tabn into my document. In normal mode it still worked as expected – coderdave May 1 '11 at 20:28
  • Edited accordingly, @coderdave. – Wuffers May 1 '11 at 20:29

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.