Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Forget Vim tabs – now you can have buffer tabs

License

NotificationsYou must be signed in to change notification settings

ap/vim-buftabline

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

74 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A well-integrated, low-configuration buffer list that lives in the tabline

Buffer basics

If you don’t know anything about buffers, the minimum you have to know is thata buffer in Vim essentially means a file, and if you sethidden, Vim can keepfiles open without necessarily displaying them on screen. You can then use the:bnext and:bprev commands to change which buffer is being displayed in thecurrent 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 hiddennnoremap <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 Vimhas 3 layers of indirection:

  1. Buffers correspond to files.

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

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

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

    Note that while windows are always associated with a buffer - i.e. an areaof the screen always shows some file –, a buffer need not be associated withany 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 notethat a buffer can be shown in any window (or no window at all), so any filecan appear any number of times in any number of tabs. Tabs and files do nothave anything to do with each other.

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

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

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

Buftabline vs. X

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

  • MiniBufExpl

    Obviously no rundown can be complete without the veteran of buffer listplugins, Mini Buffer Explorer. There are two major differences:

    1. Buftabline uses the tabline while MiniBufExpl renders to a special bufferin a split. The tabline is newer than MiniBufExpl, and unlike a buffer, itis guaranteed to stick to the top of the screen within Vim, unaffected byany splits.

    2. Because Buftabline uses the tabline, it cannot offer any functionalityrelating to the management of buffers: all it does is show you the list.

      OTOH, this also makes Buftabline very lightweight from a user perspective:Vim has plenty of facilities for managing buffers and with Buftabline youwill be using those same as without it. Buftabline need not aspire to beyour sole interface to Vim’s buffers.

  • buftabs

    Buftabs is what you get when you try to implement Buftabline on a Vim thatdoes not yet have thetabline. It can only render your tabs near or at thebottom of the Vim screen, and you have the choice between trading in yourstatusline for the list, or having it flicker “behind” the command line. IfMiniBufExpl is too heavy for you, buftabs is the best you can do in absenceof thetabline.

    I used this for a long time.

  • bufferline

    Essentially a newer rendition of buftabs.

  • Airline

    If you already use Airline, you do not need Buftabline: the functionalitycomes built in – see:help airline-tabline.

    If you do not already use Airline, you may not want to: it is far heavierthan Buftabline, to the point of dragging down performance. C.f.Pretty statuslines vs cursor speed

  • BufLine

    This is very similar in scope and strategy to Buftabline, but not nearly assimple. The code is more than 5 times as long. There are lots of options andmappings so despite its limited scope compared to something like MiniBufExplor Airline, it feels like a Big Plugin – one that requires a large up-frontcommitment. And subjective though this is, I will call its default colorsugly (while the ones in Buftabline depend entirely on your colorscheme), nordoes it make any attempt to harmonise with the user colorscheme.

  • WinTabs

    This is another Big Plugin, though much, much better. It supports Vim tabsin addition to buffers, and tries to implement a functionality that is notnative to Vim tabs: scoping buffers to certain tabs. This means it alsoneeds to hook into sessions in order to support them, which it does. All inall, if you want to use Vim tabs (i.e. viewports), this is probably the bestplugin for you – Buftabline will be too simplistic for your preferences.

About

Forget Vim tabs – now you can have buffer tabs

Topics

Resources

License

Stars

Watchers

Forks

Contributors8


[8]ページ先頭

©2009-2025 Movatter.jp