A Neovim plugin that provides a convenient way to close buffers, windows, or exit Vim with the same single keypress.
demo.mp4
- Close the current window if there are multiple windows opening the current buffer
- Close the current buffer if there are multiple buffers open
- Exit Vim if it's the last buffer
- Automatically sets up key mappings for normal file buffers
- Configurable close key
You can install this plugin using your preferred package manager. Here are examples for some popular ones:
Using vim-plug
Add the following line to your init.vim or .vimrc:
Plug 'psjay/buffer-closer.nvim'Then run :PlugInstall in Neovim.
Using packer.nvim
Add the following to your Neovim configuration:
use 'psjay/buffer-closer.nvim'Then run :PackerSync in Neovim.
Using lazy.nvim
Add the following to your Neovim configuration:
{
'psjay/buffer-closer.nvim',
config = function()
require('buffer-closer').setup()
end
}To configure the plugin, call the setup function in your Neovim configuration:
require('buffer-closer').setup({
close_key = 'q',
})close_key: The key to use for closing buffers/windows. Default is 'q'.
Once installed and configured, the plugin will automatically set up key mappings for normal file buffers. Press the configured close_key (default: 'q') in normal mode to:
- Close the current window if there are multiple windows opening the current buffer
- Close the current buffer if there are multiple buffers open
- Exit Vim if it's the last buffer
Buffer Closer provides two user commands to enable or disable the plugin functionality:
- :
BuffClsDisable: Temporarily disables the Buffer Closer plugin. When disabled, the close_key will perform its default Neovim action. - :
BuffClsEnable: Re-enables the Buffer Closer plugin after it has been disabled.