If you have a nerdtree file navigation window on the left of the current buffer
:bd1, you will find that the nerdtree window will occupy the whole
window. When you open another buffer, you have to manually resize the nerdtree
window to a smaller size, which is super annoying.
How to prevent this behaviour?
An easy way is to switch to another buffer first, and then delete the previous buffer. We can create a shortcut for this:
nnoremap \d :bp<cr>:bd #<cr>
In the above command,
:bp stands for
:bprevious, which will change the
buffer to the previous buffer.
# after the
:bd command represents the last
used buffer, i.e., the buffer we want to delete.
There is also a Nvim plugin called
vim-bufkill, which specifically
address this issue. After installing this plugin, you can use
:BD to delete
the current buffer without closing the window.
License CC BY-NC-ND 4.0