17

When using NERD Tree on MacVim, I can open a file in a new tab by using 't' (or 'T' to open it in the background) in the NERD Tree window, but when I switch to that tab, the NERD Tree window is no longer visible since it remains in the original tab. Is there a way to automatically open NERD Tree in new tabs when opening files from NERD Tree in new tabs? Or can NERD Tree persist across tabs?

Aaron Massey
  • 3,826
  • 1
  • 28
  • 26

3 Answers3

57

This NERDTree behavior was a pain for me, too. It annoyed me so much that I learned VimScript and made a plugin that keeps NERDTree consistent across all tabs all the time.

You can grab it on Github: https://github.com/jistr/vim-nerdtree-tabs

Jiří Stránský
  • 1,331
  • 1
  • 10
  • 5
15

You can also use :NERDTreeMirror. I prefer this to NERDTreeToggle when at least one tree is already open because it keeps the tree consistent across tabs.

Alexander
  • 372
  • 1
  • 2
  • 8
5

The only persistent object in Vim is a buffer. Windows display buffers, tab pages organize windows. If you want to open NERD Tree in the new tab, then call :NERDTreeToggle. Another option would be to open a new tab, open NERD Tree, and then open the file in your freshly created tab.

I wonder, though, why you would want to have a file tree open all the time. It's just a waste of space, most of the time. You can map a key to call :NERDTreeToggle to easily make it visible when you actually need to use it.

jamessan
  • 41,569
  • 8
  • 85
  • 85