Reputation: 19315
I want to be able to o
or double click on a file in NERDTree, and have it open in a split to the right, and have NERDTree stay open. I haven't found the magic dust to sprinkle on my .vimrc to make this happen yet, can anyone help?
I'd want to to behave like any GUI text editor, where the explorer persists and the files open and close in the 'main pane'.
Thanks for any insight!
Upvotes: 4
Views: 3592
Reputation: 2968
By putting the following lines in your .vimrc config will open NERDTree automatically when vim starts up on opening a directory vim ReactProjectFolder
and prevent NERDTree from hiding when first selecting a file
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | wincmd p | ene | exe 'NERDTree' argv()[0] | endif
Taken from the nerdtree f.a.q
Upvotes: 1
Reputation: 39797
Try this in your .vimrc
:
:let NERDTreeQuitOnOpen = 0
I find the following mappings useful:
nnoremap <Leader>d :let NERDTreeQuitOnOpen = 1<bar>NERDTreeToggle<CR>
nnoremap <Leader>D :let NERDTreeQuitOnOpen = 0<bar>NERDTreeToggle<CR>
So \d
opens a NERDTree that closes on file selection, while \D
opens a persistent/pinned NERDTree.
Upvotes: 11