Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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.

like image 847
vehomzzz Avatar asked Dec 09 '10 22:12

vehomzzz


People also ask

How do I close current buffer in Vim?

Just use :h enew together with :bd # to delete the last buffer afterwards.

How do I delete a window in Vim?

If you want to close the windows split, use :close . The :quit command will work, too, but has the side effect of closing Vim when this is the last window. If you know how Vim deals with buffers, this is a recommended option that many users have set.

How do I close a window in Neovim?

^Wc (or :close[!] ) closes the current window. If the hidden option is set and this is the last window referencing this file, Vim closes the window and the buffer is hidden. If this window is on a tab page and is the last window for that tab page, the window and the tab page are closed.


1 Answers

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

like image 199
Laurence Gonsalves Avatar answered Oct 12 '22 23:10

Laurence Gonsalves