Vim close buffer with nerdtree

My current use case: I have a buffer opened with NERDTree (Left) and 1 with the file being edited (right)

Let's also assume that there are 2 more files in the background buffers open as well.

enter image description here

If I press c (shortcut to close the buffer, basically: bd), the right side disappears and only the left side is displayed. But when closing the buffer, I would expect vim to close the current file buffer and save the right side to open one of the buffers that are in the background.

enter image description here

How do you achieve the expected behavior?

+3


source to share


2 answers


you can use

nnoremap c :bp\|bd #<CR>

      



First go to the previous buffer and then delete the last buffer. This way it will close the buffer and go to the previous one.

+13


source


Maybe bufkill can fix the problem for you.



0


source







All Articles