- Notifications
You must be signed in to change notification settings - Fork24
bagrat/vim-buffet
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Brings you the IDE-like tabs into Vim, for easy navigation, and a nice, customizable look
Installation •Usage •Recommendations •FAQ •Credits •License
Note: This plugin has been renamed fromvim-workspace
and thus has alsodifferent prefix for the configuration and commands. Please revisit the READMEand use the new names of the configuration parameters, highlight groups andcommands. Sorry for inconvenience.
Vim-buffet takes your buffers and tabs, and shows them combined in thetabline. With this you always have your list of buffers visible, at the sametime not losing visibility into tabs. Moreover,vim-buffet
provides handycommands to boost navigation as well as a list of options to customize how thetabline appears.
If you are new to the Vim world, then welcome, and start by learning Vim'snotions ofbuffers, windowsandtabpages.
But if you are an experienced Vim user, you might have got tired ofbn/bp/ls/Ctrl-^
.
Take a look at the screenshot. The blue cuties are the tabpages. The tabpagethat has the buffers list coming next, is the current tabpage. The gray itemswith names are the hidden/inactive buffers, and obviously, the green one is thecurrent buffer. The brighter items on both ends with the little arrows and numbersare the truncation indicators. If all the buffers do not fit the screen,vim-buffet
truncates the tabline, and shows the number of truncated buffers onboth ends.
Note: The instance of Vim in the screenshot is configured to use powerlinesymbols and dev-icons. The default interface is only text and will work withoutrequiring any patched fonts. The default interface looks like in the screenshotbelow.
Use your favourite plugin manager to installvim-buffet
. If you do not have anypreference or have not decided yet, I would recommendPlug.
Plug'bagrat/vim-buffet'
After installation,vim-buffet
is enabled by default, so whenever you restartVim, you will see the new tabline!
Apart from listing the buffers in the tabline,vim-buffet
also provides somehandy commands to manipulate the buffers:
Bw[!]
- wipe the current buffer without closing the window. If it has unsavedchanges, an error will be shown, and the buffer will stay open. To ignore anychanges and forcibly wipe the buffer, useBw!
.Bonly[!]
- wipe all the buffers but the current one. If there are any buffersin the list that has unsaved changes, those will not be wiped. To ignore anychanges and forcibly wipe all buffers except the current one, useBonly!
.
Mappings for switching buffers are also provided. You just need to add the followingmappings to your Vimrc file:
nmap<leader>1<Plug>BuffetSwitch(1)nmap<leader>2<Plug>BuffetSwitch(2)nmap<leader>3<Plug>BuffetSwitch(3)nmap<leader>4<Plug>BuffetSwitch(4)nmap<leader>5<Plug>BuffetSwitch(5)nmap<leader>6<Plug>BuffetSwitch(6)nmap<leader>7<Plug>BuffetSwitch(7)nmap<leader>8<Plug>BuffetSwitch(8)nmap<leader>9<Plug>BuffetSwitch(9)nmap<leader>0<Plug>BuffetSwitch(10)
This will allow you to switch between buffers 1 - 10. You can get more<Plug>
mappings, or disable it completely, by configuring theg:buffet_max_plug
option.
There are some configuration options that make it possible to customize how thetabline works and looks like.
Options | Default | Descriptions |
---|---|---|
g:buffet_always_show_tabline | 1 | Set to0 , the tabline will only be shown if there is more than one buffer or tab open |
g:buffet_powerline_separators | 0 | Set to1 , use powerline separators in between buffers and tabs in the tabline (see the first screenshot) |
g:buffet_separator | '' | The character to be used for separating items in the tabline |
g:buffet_show_index | 0 | Set to1 , show index before each buffer name. Index is useful for switching between buffers quickly |
g:buffet_max_plug | 10 | The maximum number of<Plug>BuffetSwitch provided. Mapping will be disabled if the option is set to0 |
g:buffet_use_devicons | 1 | If set to1 andvim-devicons plugin is installed, show file type icons for each buffer in the tabline. If thevim-devicons plugin is not present, the option will automatically default to0 (Note: you need to havevim-devicons loaded beforevim-buffet in order to make this work) |
g:buffet_tab_icon | '#' | The character to be used as an icon for the tab items in the tabline |
g:buffet_new_buffer_name | '*' | The character to be shown as the name of a new buffer |
g:buffet_modified_icon | '+' | The character to be shown by the name of a modified buffer |
g:buffet_left_trun_icon | '<' | The character to be shown by the count of truncated buffers on the left |
g:buffet_right_trun_icon | '>' | The character to be shown by the count of truncated buffers on the right |
g:buffet_hidden_buffers | ['terminal', 'quickfix'] | The types of buffers to hide from the tabline (Note: This has the side effect of making all matching buffers unlisted) |
Of course, you can customize the colors of your tabline, to make it awesome andyours. To get your custom colors set, define a function with nameg:BuffetSetCustomColors
and place your highlight group definitions insidethe function.
" Note: Make sure the function is defined before `vim-buffet` is loaded.function!g:BuffetSetCustomColors()hi! BuffetCurrentBuffer cterm=NONE ctermbg=5 ctermfg=8 guibg=#00FF00 guifg=#000000endfunction
The following is the list of highlight groups, with self-explanatorynames:
Highlights | Descriptions |
---|---|
BuffetCurrentBuffer | The current buffer. |
BuffetActiveBuffer | An active buffer (a non-current buffer visible in a non-current window) |
BuffetBuffer | A non-current and non-active buffer. |
BuffetModCurrentBuffer | The current buffer when modified. |
BuffetModActiveBuffer | A modified active buffer (a non-current buffer visible in a non-current window). |
BuffetModBuffer | A modified non-current and non-active buffer. |
BuffetTrunc | The truncation indicator (count of truncated buffers from the left or right) |
BuffetTab | A tab |
Here are some recommended mappings to boost your navigation experience:
noremap<Tab>:bn<CR>noremap<S-Tab>:bp<CR>noremap<Leader><Tab> :Bw<CR>noremap<Leader><S-Tab> :Bw!<CR>noremap<C-t>:tabnew split<CR>
How do I get the look like in the screenshot?
First you will need a patched font, extended withpowerline
andfont-awesome
symbols. Also, you will need thevim-devicons
installed, whichalso has great guides on how to patch fonts, as well as some pre-patched fonts.As soon as you have the patched font, setting the following options, will giveyou exactly the same tabline as you see in the first demo screenshot:
letg:buffet_powerline_separators=1letg:buffet_tab_icon="\uf00a"letg:buffet_left_trunc_icon="\uf0a8"letg:buffet_right_trunc_icon="\uf0a9"
Note: you need to havevim-devicons
loaded beforevim-buffet
in order tomake this work.
How to have the current buffer open in a new tab instead of a new one?
Just add this mapping to your Vimrc:
map<C-t>:tab split<CR>
I can only see the current active buffer in the tabline
The reason is that you probably use some statusline plugin (e.g. lightline,airline) that also has tabline support, which overrides vim-buffet. All you needto do is disable the tabline of the statusline plugin.
It should be something like this:
letg:lightline.enable.tabline=0
If that's not working, checkout thisissue especially thiscomment.
SeeLICENSE.