Thursday, June 30, 2011

Navigation between Vim tabs

I like working with tabs in Vim. It is a quite handy feature. But the navigation between tabs is not easy. It requires to be in command mode and type commands. It is certainly not a quick way and specially if you are jumping between tabs frequently you will soon get tired typing the commands. So I mapped the F7 and F8 keys to go to previous and next tabs respectively. Basically one can map any two keys of his choice to do that. Here is what I added in my vimrc file:

map <F7> :tabp<Enter>
map <F8> :tabn<Enter>
imap <F7> <Esc>:tabp<Enter>
imap <F8> <Esc>:tabn<Enter>

I used both map and imap commands because one works in Ubuntu Linux but not when I use iTerm in Mac OS X and vice versa.

No comments: