I recently started using Vim with NERDTree. The annoying thing is when I close the buffer, NERDTree expands to fill the rest of the screen, and I have to open another file and reopen NERDTree to get it back to the old layout.

Is there a way to "lock" NERDTree in place? Ideally, closing a buffer would replace it with another buffer that's hidden, or open a new blank buffer if no other buffers are open.

Thanks!

link|improve this question
feedback

3 Answers

up vote 2 down vote accepted

i do not think so. the only solution which comes to mind is to create a new keybinding which

  • :vnew
  • ctrl-w left
  • ctrl-w q

instead of just closing the current buffer.

link|improve this answer
Sucks that you can't really do it, although that solution is a very nice workaround. Thanks! – breadjesus May 21 '10 at 15:04
feedback

Take a look at http://github.com/carlhuda/janus, it's a customised version of vim that let's you keep nerdtree locked on the left. It also includes many other popular plugins like command-t, ctags and ack.

link|improve this answer
Or, if you don’t want to use that entire distribution, you could simply jack the portion of that vimrc that maintains NERDTree for you. It’s pretty slick! – elliottcable Jun 5 '11 at 5:42
feedback

Try bufkill. It's built to solve this exact problem.

Instead of :bd to close your buffer, you use :BD. This prevents the window from being closed just because you killed the buffer. If there isn't another available buffer to replace it with, an empty buffer is opened.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.