vehomzzz
vehomzzz

Reputation: 44568

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

I usually type :bd to remove the buffer, however, it results in undesirable side-effect of the window being closed which I do NOT want.

Upvotes: 24

Views: 4706

Answers (4)

Rumple Stiltskin
Rumple Stiltskin

Reputation: 10375

Try kwbdi(Keep Window on Buffer Delete) plugin. Worked well for me.

Upvotes: 0

ggustafsson
ggustafsson

Reputation: 633

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.

Upvotes: 9

Laurence Gonsalves
Laurence Gonsalves

Reputation: 143064

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

Upvotes: 35

Jason Down
Jason Down

Reputation: 22151

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.

Upvotes: 4

Related Questions