In Vim, trying to unload, delete or wipe a buffer without closing the window or split? You'll like this:
Without bufkill (standard Vim behaviour):
The inspiration for this script came from:
- My own frustration with vim's lack of this functionality
- The description of the emacs kill-buffer command in tip #622 (this script basically duplicates this command I believe, not sure about the undo functionality)
- Comments by Keith Roberts when the issue was raised in the email@example.com mailing list.
Note: This is the official Git repo which replaces http://www.vim.org/scripts/script.php?script_id=1147
This plugin follows the standard runtime path structure, and as such it can be installed with a variety of plugin managers:
git clone https://github.com/qpkorr/vim-bufkill ~/.vim/bundle/vim-bufkill
When you wish to unload a file from the buffer and keep the window/split intact:
When you wish to delete a file from the buffer and keep the window/split intact:
When you wish to wipe a file from the buffer and keep the window/split intact:
Notice how the key mappings are the uppercase version of the
:bw Vim commands? Easy!
Moving through buffers
To move backwards through recently accessed buffers:
and to move forwards:
To move to an alternate buffer and keep the cursor in the same column, use:
You can also override
Ctrl-^ (Vim's default for swapping between alternate buffers) via
g:BufKillOverrideCtrlCaret in your
You can overide the default mappings within your
/.vimrc file like so:
map <C-c> :BD<cr>
resulting in being able to delete a file from the buffer via vim-bufkill with CTRL + c
Contributions and pull requests are welcome.
A big thanks to Oli Morris for his excellent rewrite of this README file, and creating the animated gifs.