I tried following the instruction in FAQ section on NERDTree github site:
"Q. How can I open a NERDTree automatically when vim starts up?"
"A. Stick this in your vimrc: autocmd vimenter * NERDTree
"
It works but when I open a file the cursor stay in the NEARDTree explorer area but not in the edit area, I have to press Ctrl+w+l
to move it back, what should I write in my .vimrc
file to automate setting the cursor in the edit area?
Just add this second command right after:
autocmd VimEnter * NERDTree autocmd VimEnter * wincmd p
Or if you want a one-liner
autocmd VimEnter * NERDTree | wincmd p
If you want to keep the default behavior if no file is specified (i.e. leave the NERDTree explorer only if there is a file to edit) you can use this setting:
autocmd VimEnter * if argc() == 1 | NERDTree | wincmd p | endif
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With