How to delete a buffer in Vim without closing the window?

I'm not sure if icecrime's bufclose plugin link is based on the same thing, but the Vim Tips Wiki shows a couple of different approaches via a script. Check them out.


nmap <leader>d :bprevious<CR>:bdelete #<CR>

Works as it should until one buffer is open in several windows. Good enough unless you want to use the bigger scripts out there.


I usually use :bn (next buffer) followed by :bd# (delete alternate buffer). You could create a mapping or command for this, of course.

Tags:

Vi

Vim