When I open a large number of files in vim with tabs only the first tabpagemax files are in tabs and any more than that are available by doing :n. After I close several of the open tabs how do I 'refresh' the tabs with the untabbed files?

  • I've found github.com/ap/vim-buftabline to be the simplest way display buffers in a similar way to tabs
    – andorov
    Oct 6, 2015 at 18:46
  • I always find it amazing how difficult it is for people to abandon their notion of 1 file = 1 tab, especially among those who have accepted modal editing. Oct 6, 2015 at 20:08
  • 1
    It's not the concepts that are hard, and you can pry the modal editing from my cold dead fingers. But I find it very useful to be able to see which 5 or so files I have open in a window without having to switch to that window.
    – andorov
    Oct 6, 2015 at 20:14

2 Answers 2


You can use :tab ball to open remaining buffers from the buffer list in new tabs. However, if you have more buffers left, than your 'tabpagemax' option, the last tab will open split windows for the remaining ones.

Perhaps this works better:

:set tabpagemax=99
:tab ball

or even :exe "tab ball" &tabpagemax


And now for something completely different...

It seems like you are using Vim's tabs as file proxies (aka 1 file == 1 tab). This is how most editors work. Vim on the other hand uses the same familiar name "tab" to be a view into window (splits) layout. This unfortunate naming has lead many a new vimmer to try and force tabs to behave as file proxies.

Vim's uses buffers. Buffers can be associated with files or simply scratch buffer not associated file. Each file has its own buffer. Buffers are Vim's file proxies.

Now windows/splits are views into a buffer. You can have many windows looking into the same or different buffers. You can move these windows around, create them, close them, or whatever you need to create a layout of buffers that meet your workflow.

Tabs are a collection of windows or a view into a layout of windows. It's just another layer above windows. You can of course use these tabs however you want, but trying to force Vim to use tabs like other editors is going to be pure folly.

But don't just take my word for it:

Oh yeah? What about Buftabline, Airline, BufTabs, MiniBufExpl, ...?

All these plugins do is show you your currently listed buffers. Maybe with some kind of positioning information so that you feel comfortable cycling via :bnext and :bprevious (or whatever mappings you might be using) through your buffer list.

Now that is great and all, these plugins have recreated other editor's version of tabs, but Vim already let you cycle through buffers without these plugins. The only thing missing was a menu which :ls will gladly do for you without wasting any screen real-estate.

Imagine having 10, 25, 50, or 100+ buffers open. How is your Buftabline going to handle that? My bet is not well. You need to stop reaching for simple tools like :bnext / :bprev and start reaching for a power tool like :b.

Behold the power of :b

The :b command can take a buffer number to switch directly to a buffer. Far more interesting, :b can take a partial filename.

:b partial-name

Need more power in your :b?

  • Uses tab completion
  • Uses <c-d> to list out completions
  • Accepts globs. e.g. :b *foo
  • Use ** to descend into directories. e.g. :b foo/**/bar
  • Don't forget to add set hidden to your vimrc. See :h 'hidden'

Why ride a bike when you can fly?

Flying vs cycling

taken from Bairui's collection of Vim infographics.

You can use a simple mapping to leverage both :ls and :b:

nnoremap <leader>b :ls<cr>:b<space>

Now you can travel directly to you buffer you want. No more cycling.

But I like plugins

Who doesn't like a good plugin. As a matter a fact if you are looking for a nice buffer switching plugin then I would recommend you look into a nice fuzzy finder like CtrlP to aid you in switching between buffers. A fuzzy finder actually adds value to switching between buffers by getting you there faster with less typing.


Eventually you workflow will require you to use more than 3 buffers at a time. At that moment I would suggest you take another look at the :b command or at the very least get a nice fuzzy finder. It will save you time and effort.

So stop riding your bike when you can fly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.