Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making NERDTree work 'as expected'

Tags:

vim

nerdtree

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!

like image 933
Alex Mcp Avatar asked Dec 17 '22 15:12

Alex Mcp


1 Answers

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.

like image 159
Jeet Avatar answered Jan 12 '23 05:01

Jeet