Wednesday, August 17, 2016

Three Minutes Daily Vim Tip: Tabs

Vim is a controversial editor: some love it, while some hate it. Vim is indeed difficult at first, requiring very steep learning curve. In order to help people, including myself, learn Vim, I am going to post a series of short Vim tips. Today is the first each the series. If you are clueless with Vim, learn the very basics first.

Starting Vim 7.0, it supports tabs. In Vim's normal mode, type in
:tabe some_file_to_open.c

You will immediately notice that the file is opened up in a new tab. To switch between tabs, type in

I have to admit that tab switching command is too long. Well, it's Vim: we can always create a one-key shortcut.

$ echo "nnoremap <F2> :tabp<CR>" >> ~/.vimrc
$ echo "nnoremap <F3> :tabn<CR>" >> ~/.vimrc

The two lines will map <F2> and <F3> keys for switching to previous and next tab, respectively.

No comments:

Post a Comment