Home

Awesome

<h1 align="center">Buftabline</h1> <div align="center"> A well-integrated, low-configuration buffer list that lives in the tabline<br> <img src="https://raw.githubusercontent.com/ap/vim-buftabline/fe615be277cfba1ecadc52d61fa173d034817d67/screenshot.png" width="787"> </div>

Buffer basics

If you don’t know anything about buffers, the minimum you have to know is that a buffer in Vim essentially means a file, and if you set hidden, Vim can keep files open without necessarily displaying them on screen. You can then use the :bnext and :bprev commands to change which buffer is being displayed in the current window, and :ls to look at the list of buffers.

If this is all news to you, you should probably add this to your configuration:

set hidden
nnoremap <C-N> :bnext<CR>
nnoremap <C-P> :bprev<CR>

For the full story, read :help windows.txt.

Why this and not Vim tabs?

Vim tabs are not very useful except in very particular circumstances. To understand why this is, you have to understand that the display in Vim has 3 layers of indirection:

  1. Buffers correspond to files.

    Not necessarily to files on disk, but in potentiality; i.e. a buffer becomes the content of a file when you do :w

  2. Windows correspond to rectangular areas on the screen, each associated with some buffer.

    Any window can be associated with any buffer, and any buffer with any window. You can change which buffer is shown in a window at any time, and you can split and resize windows to create any on-screen arrangement you want. So you could have 3 windows showing the same buffer, e.g. to work on several areas of a file at once.

    Note that while windows are always associated with a buffer - i.e. an area of the screen always shows some file –, a buffer need not be associated with any window – i.e. a file may be loaded without being shown on screen.

  3. Tabs correspond to entire screens, i.e. to an arrangement of windows.

    In other windowing environments this concept is often called a viewport, or a virtual desktop. Each window belongs to one particular tab. But note that a buffer can be shown in any window (or no window at all), so any file can appear any number of times in any number of tabs. Tabs and files do not have anything to do with each other.

Now it is possible to open just one full-screen window in each tab, and in each window edit a different buffer, in effect associating tabs with files. But this only works if you stay away from any other window or buffer management, i.e. if you never create splits and never touch the buffer list. Even then there are parts of Vim (such as the help function and the netrw Explorer) that expect to be working with windows, not tabs, and so can easily inadvertently shatter the illusion.

So if you consider what Vim tabs actually are, i.e. viewports, and you use Vim in a typical way, there are only very limited circumstances in which you will ever need such functionality, if at all.

What the typical user wants when they think of tabs is simply the ability to open multiple files and then flip between them, which in Vim means they want buffers – not tabs.

Buftabline vs. X

As of Nov 15, 2014, here is how Buftabline compares with some other plugins of which I am aware that they offer related functionality, roughly in order of their age.

<!-- vim: et fenc=utf8 -->