Vim close buffer with nerdtree
Asked Answered
R

2

10

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.

enter image description here

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.

enter image description here

How do I achieve the expected behavior?

Roughandtumble answered 4/8, 2015 at 9:41 Comment(0)
D
30

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.

Dignadignified answered 4/8, 2015 at 10:7 Comment(0)
A
4

May be bufkill can solve this issue for you.

Aileenailene answered 9/3, 2018 at 10:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.