Take the 2-minute tour ×

In Using vim's tabs like buffers:

This is not how vim's tabs are designed to be used. In fact, they're misnamed. A better name would be "viewport" or "layout", because that's what a tab is -- it's a different layout of windows of ALL of your existing buffers.

If each tab in vim is just a different layout of all existing buffers (so doing :ls in each tab, shows the same list), isn't the existence of tabs in vim useless? If I can use plugins to handle buffers like minibufexplorer and such, why do tabs exist? Shouldn't at least buffers opened in a tab be shown when doing :ls only on that tab (acting somehow like a "workspace" feature)?

I think that having multiple tabs with different files opened, but when trying to do :bn on the tabs it goes to all opened buffers, it becomes a mess. Some people like to open different tabs for each "domain" of problem when developing, but I to me it would be really useful if it was possible to have a different buffer list for each tab in Vim.

(I have search SO a lot, and couldn't find WHY tabs exist, only "stop using tabs in vim like tabs in others editors, use buffers instead", so why do tabs in vim were implemented? That's why I don't think this question is a duplicate)

Summarizing... How do you feel about this subject - usefulness of tabs in Vim when programming? How do you use it?

share|improve this question
This is a subjective question, so you may not get too far with it. –  the Tin Man Apr 4 '11 at 0:06

3 Answers 3

up vote 2 down vote accepted

Tabs can each have their own working directory which makes grouping and working with similar groups of files much more convenient.

Also, directly from :help tabpage:

the current window layout.  Open a new tab page, do whatever you want
to do and close the tab page.
share|improve this answer
Hum, I've heard about the possibility of different working directories, that's why I'm asking: since each tab can have it's own working directory, why they can't have it's own buffer list by default? Isn't this a design flaw? –  Somebody still uses you MS-DOS Apr 4 '11 at 0:42
It's more of a design decision. If I had to guess, the fact that tabs came along so recently in vim's development (relatively) probably hindered what exactly was possible with them without a complete rewrite. Think of how many commands and things make assumptions about a single buffer list. Purely speculation of course. –  Randy Morris Apr 4 '11 at 0:51
Well, a good point. "Think of how many commands and things make assumptions about a single buffer list". Indeed that are more things I'm unaware of about this design decision. –  Somebody still uses you MS-DOS Apr 4 '11 at 1:10
Personally, I find editors that don't let me have multiple files visible in a single window to be limiting. –  the Tin Man Apr 4 '11 at 7:28

I use tabs often, and use them to logically group files.

For instance, I'll open views or HTML in one tab, in another have the associated controllers and another has the associated models. Then I'll save out the layout using :mksession! and reload it later with the -S flag.

Other times I'll use tabs to keep one of vim's help pages open just so it's immediately available.

I think the main thing is tabs allow you to organize your buffers in a different way than using split windows and that flexibility allows vim to work with more people's brains, because we all think differently.

This answer to a related question might help: Using vim's tabs like buffers

I normally use the -O flag to open files in split windows, but if you insist on opening them in separate tabs you can use -p. I prefer splits because I can easily see two separate files side by side, something you can't do with tabs.

And finally, here's some key defs I use to make it easy to move between splits:

" Switch between window splits using big J or K and expand the split to its
" full size.
" Move vertically in the window through the horizontal splits...
map <C-J> <C-w>j<C-w>_
map <C-K> <C-w>k<C-w>_

" Move horizontally in the window through the vertical splits...
map <C-H> <C-w>h<C-w>\|
map <C-L> <C-w>l<C-w>\|
share|improve this answer

I normally use tabs when my current view is split as much as it can while still allowing me to read and program efficiently. Most of the time it is there so that I have quick access to the information of that file (generally some kind of include file).

I rarely use tabs for actual development but rather a placeholder for information that I want to occasionally look at.

So normaly I have

Tab0 -> source file and test file
Tab1 -> include file and sometimes a related interface file

share|improve this answer

Your Answer


