One of the most talked about features of Vim7 are tabs, but I don’t like them very much, I think they should have been given a different name. They could have been called layouts, for example, because they are very different from what most people expect and much more similar to Eclipse’s perspectives or NetBeans workspaces than to Firefox tabs.
I find buffers, which have been in Vim since pretty much forever, are a very convenient way to edit multiple files. You just have to tune them a bit.
First, you absolutely have to set the hidden option, so you can switch between buffers without being forced to save them, and then you need some key mappings:
set hidden
map <C-TAB> :bnext!<CR>
map <C-S-TAB> :bprev!<CR>
map <C-\> :b#<CR>
Use Ctrl-Tab and Ctrl-Shift-Tab to navigate through the list of open buffers and Ctrl-\ to quickly toggle between two open files.
After using this setup for quite some time, about a week ago I found buftabs, a simple plugin that displays the open buffers in the status line. I like simple plugins, my rule is that they have to be useful without me having to actually learn to use them or even remember they are there.
set laststatus=2
let g:buftabs_in_statusline=1
I then added two more mappings to navigate through buffers, to better match the visual representation buftabs provides.
map <C-b> :bprev!<CR>
map <C-n> :bnext!<CR>
With these switching buffers is even easier, as you have a visual indication of which buffer you are going to activate.
Just one last piece was missing from this picture: most tabs implementations allow you to directly activate a tab by pressing the Alt key and a number, like Firefox, for example.
So here comes my first Vim script ever: bufpos is a very simple script that maps Alt-number keys to activate buffers.
Note that you don’t have to use the buffer number buftabs puts beside the file name, but the position in the buffers list.