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.


3 Answers 3


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.

  • Sucks that you can't really do it, although that solution is a very nice workaround. Thanks!
    – breadjesus
    May 21, 2010 at 15:04

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.

  • 1
    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! Jun 5, 2011 at 5:42
  • Good call - it seems to be in janus/vim/tools/janus/after/plugin/nerdtree.vim.
    – James M
    May 23, 2013 at 12:12
  • Ok, this is what I put in my vimrc, and it works a treat. Thanks a lot!
    – James M
    May 23, 2013 at 12:30

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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