Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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!

share|improve this question
add comment

3 Answers 3

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.

share|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
add comment

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.

share|improve this answer
add comment

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.

share|improve this answer
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! –  elliottcable Jun 5 '11 at 5:42
    
Good call - it seems to be in janus/vim/tools/janus/after/plugin/nerdtree.vim. –  James McLaughlin May 23 '13 at 12:12
    
Ok, this is what I put in my vimrc, and it works a treat. Thanks a lot! –  James McLaughlin May 23 '13 at 12:30
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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