How to Delete Multiple Buffers in Vim/NeoVim
I always confuse how to delete buffers from A to B like from 3 to 12. I typically write:
:bd[elete] 3,15
However the true form is:
:3,12bd[elete]
Another useful ones
Delete all buffers
:%bd[elete]
Delete buffers from the current one to the last except last one
:.,$-bd[elete]
Delete all buffers except current one
:%bd|edit#|bd#
It may be good idea to map these to some commands and key-bindings:
"~/.vimrc
" Close all buffers but current
nnoremap <C-B>c :BufCurOnly<CR>
command! BufCurOnly execute '%bdelete|edit#|bdelete#'
All done!
Subscribe
Read Related