Is it possible to open NERDTree in every tab with pressing t or T in NERDTree, if yes, How?
-
How do you open it in split view? It works, but it opened the file over it when i double clicked on the file. vim newbie here... – ma11hew28 Jun 23 '10 at 16:26
7 Answers
autocmd VimEnter * NERDTree
autocmd BufEnter * NERDTreeMirror
edit: The above command seems to open the new tab in NERDTree's buffer. Instead use this as mentioned by wejrowski in the comment below :
autocmd BufWinEnter * NERDTreeMirror

- 3
- 2

- 1,157
- 1
- 7
- 2
-
7
-
6I did this and when I open a file through nerdtree in a new tab "t" it opens the file in a new tab in the side nerdtree panel and makes the main area blank. so there's no nerdtree anymore. – wejrowski Nov 20 '12 at 21:55
-
6Hmm I fixed it by swapping "autocmd BufEnter * NERDTreeMirror" with "autocmd BufWinEnter * NERDTreeMirror".. seems like it was opening nerdTree then using that nerdtree window to open the buffer – wejrowski Nov 20 '12 at 23:30
-
2this is the wrong answer. use nerdtreetabs. nerdtree is garbage without it – Andy Ray Feb 14 '13 at 19:10
-
I wrote a vim plugin that does this and also adds some goodies on top (i.e. keeps all trees in sync, ensures meaningful tab captions - not captions like 'NERD_tree_1' etc.).
It's here on Github: https://github.com/jistr/vim-nerdtree-tabs

- 1,331
- 1
- 10
- 5
-
this plugin seems to work really well, fixes all of these types of shortcomings in NERDTree. Good job! – Daniel OCallaghan Dec 14 '11 at 04:00
-
1
-
-
Thanks so much for writing this dude -- super useful! It still works with the latest version of NERDTree -- hopefully it continues to work. – Luke Davis Nov 27 '17 at 21:43
autocmd VimEnter * NERDTree
autocmd BufEnter * NERDTreeMirror
autocmd VimEnter * wincmd w
This one is a little better than Dustin's one because it places the cursor directly on the file you are intending to edit for quick edits. Thanks dustin for the original example ^^

- 1,001
- 11
- 16
A better solution is to open NERDTree only if there are no command line arguments set.
" Open NERDTree in new tabs and windows if no command line args set
autocmd VimEnter * if !argc() | NERDTree | endif
autocmd BufEnter * if !argc() | NERDTreeMirror | endif
NERDTree is e.g. not helpful if you do a git commit
or something similiar.

- 480
- 6
- 10
This is probably not the best way, but if you edit plugin/NERDTree.vim and change this:
exec "nnoremap <silent> <buffer> ". g:NERDTreeMapOpenInTab ." :call <SID>openInNewTab(0)<cr>"
to this:
exec "nnoremap <silent> <buffer> ". g:NERDTreeMapOpenInTab ." :call <SID>openInNewTab(0)<cr>:NERDTree<cr>"
it will alter the binding of 't' in the NERDTree view to first open the file and then open NERDTree. Note, that the NERDTree views will not keep in sync.

- 31,467
- 8
- 60
- 69
How about toggling it.
" in .vimrc
" NERDTree, Use F3 for toggle NERDTree
nmap <silent> <F3> :NERDTreeToggle<CR>
In OSX, you just need to fn-F3 to toggle NERDTree.

- 31,901
- 69
- 184
- 271
This problem was actually mentioned in the official Repository's Readme file including three situations related to opening NERDTree automatically:
How can I open a NERDTree automatically when vim starts up?
Stick this in your vimrc: autocmd vimenter * NERDTree
How can I open a NERDTree automatically when vim starts up if no files were specified?
Stick this in your vimrc:
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
Note: Now start vim with plain vim
, not vim .
How can I open NERDTree automatically when vim starts up on opening a directory?
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | endif
This window is tab-specific, meaning it's used by all windows in the tab. This trick also prevents NERDTree from hiding when first selecting a file.

- 1,595
- 2
- 19
- 30