My current use case is: I have a buffer open with a NERDTree (Left) and 1 with a file being edited (Right)
Lets also assume 2 other files in background buffers are open as well.
If i press c (shortcut for closing buffer, basically :bd), the Right side is gone and only the left side is displayed. But when closing a buffer, i would expect that vim will close the current file buffer and keep the right side to open one of the buffers that are in the background.
How do I achieve the expected behavior?
If you want to close NERDTree window make sure you are inside the NERDTree menu. You can switch windows by using ctrl+w then type :q to close NERDTree window so that you will be left with the window for editing your code.
Assuming the default backslash leader key, you can also press \bd to close (delete) the buffer in the current window (same as :Bclose ).
I normally switch screen in vim using ctrl+h or ctrl+l to switch between NerdTree and vim main window. Vim8 got :term command to bring up terminal which is great!
Press m to bring up the NERDTree Filesystem Menu. This menu allows you to create, rename, and delete files and directories.
You can use
nnoremap c :bp\|bd #<CR>
Which will first go to the previous buffer, then delete the last buffer. This way it will both close the buffer and go to the previous one.
May be bufkill can solve this issue for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With