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?
3 Answers
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

- 1,331
- 1
- 10
- 5
-
This is wonderful. Definitely what I and and the original author was looking for; should be the official answer since this doesn't require anymore key strokes from the user once set up. – Jonathan Dumaine Sep 28 '11 at 08:46
-
1Thank you, Thank you, thank you. Your plugin makes NERDTree useful. I use it all day every day. – Peter Anselmo Apr 29 '12 at 13:58
-
9Thanks everyone for letting me know you like the plugin, it makes me feel happy :) – Jiří Stránský May 02 '12 at 10:45
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.

- 372
- 1
- 2
- 8
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.

- 41,569
- 8
- 85
- 85