How to delete a buffer in Vim without losing the split window?
bp|bd #
will do it.
Details: The bp
command (“buffer previous”) moves us to a different buffer in the current window (bn
would work, too), then bd #
(“buffer delete” “alternate file”) deletes the buffer we just moved away from. See :help bp
, :help bd
, and :help alternate-file
.
I really like bufkill.vim there is a github repo as well
You can add the following to your .vimrc
to have Bd
work as bd
but without touching the window splits:
command Bd bp\|bd \#
I found this as a useful complement to what Mud answered.