www-gem words

[Plugin] Buffers tabs in neovim: barbar

Published on

vim Keeping your opened files organized has always been a challenge and people have developed tools to help us with this task (windows manager, windows switchers, file explorers…) but tabs are certainly one of the biggest player here. We use them everywhere from text editors to web browsers.
Neovim is no exception and offers a variety of ways to manage your buffers. My personal preference went for barbar.nvim

╭── What is barbar.nvim?

From the github page “it is a tabline plugin with re-orderable, auto-sizing, clickable tabs, icons, nice highlighting, sort-by commands and a magic jump-to-buffer mode. Plus the tab names are made unique when two filenames match.”

In one sentence you’re presented with all the features that this plugin has. It allows you to keep an eye on your open buffers by assigning tabs to them and it renders the manipulation of your files extremely convenient and efficient thanks to a very high level of customization.
Actually, this plugin is not deliver with a default configuration (though there is examples on the github page) leaving you complete freedom to come up with what works for you.

╭── Lots of features but they’re all useful

╭── No default mappings

As mentioned earlier, there is no default configuration for this plugin but - in addition to examples on the github page - here are the keybindings I use (in lua) in case you can get some inspiration from these:

vim.keymap.set( 'n', 'b', ':BufferPick<CR>') -- jump-to-buffer mode will wait for the letter to jump to its associated buffer
vim.keymap.set( 'n', 'bp', ':bp<CR>') -- jump to previous buffer 
vim.keymap.set( 'n', 'bn', ':bn<CR>') -- jump to next buffer
vim.keymap.set( 'n', 'b1', ':BufferGoto 1<CR>') -- jump to buffer #1
vim.keymap.set( 'n', 'b2', ':BufferGoto 2<CR>') -- jump to buffer #2
vim.keymap.set( 'n', 'b3', ':BufferGoto 3<CR>') -- jump to buffer #3
vim.keymap.set( 'n', 'b4', ':BufferGoto 4<CR>') -- jump to buffer #4
vim.keymap.set( 'n', 'b5', ':BufferGoto 5<CR>') -- jump to buffer #5
vim.keymap.set( 'n', 'b6', ':BufferGoto 6<CR>') -- jump to buffer #6
vim.keymap.set( 'n', 'b7', ':BufferGoto 7<CR>') -- jump to buffer #7
vim.keymap.set( 'n', 'b8', ':BufferGoto 8<CR>') -- jump to buffer #8
vim.keymap.set( 'n', 'b9', ':BufferGoto 9<CR>') -- jump to buffer #9
vim.keymap.set( 'n', 'bb', ':enew<CR>') -- create a new empty buffer

Thanks for your read. Hope it's been useful to you.


Interact with this post using Mastodon or

Comment on wwwgem's post

Copy and paste this URL into the search field of your favourite Fediverse app or the web interface of your Mastodon server.

✄ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈

More food for thoughts? Check other posts about: #(Neo)vim #(Neo)vim-Plugins