I just started playing around with NERDtree and VIM and can't figure out how to make NERDtree NOT be the default window when it opens.
I'd like to open NERDTree in one pane and the relevant file in another but instead of having the NERDTree tab take focus when it opens, have the file I am editiing by the default focus.
I have looked at the github project but the behavior for how to change this isn't obvious to me. Everything else is working perfectly.
Is there a configuration that specifies which window to focus on in VIM itself when it starts or is this a NERDtree specific configuration that needs to be set?
EDIT:
Relevant .vimrc
config:
" Open Nerdtree automatically
autocmd vimenter * NERDTree
" Close Nerdtree if no files specified
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
" Nerdtree behavior
map <C-n> :NERDTreeToggle<CR>
let NERDTreeHighlightCursorline=1
(1) Thus, if your edit window is to the right of the NERDTree window, you would use: ctrl + W l to go to right window and ctrl + W h to go to left window. or ctrl + w twice to toggle between the two. Hit ENTER to end the search at the line, and then ENTER again to open the file in the previous window and go to it.
If you want to close NERDTree window make sure you are inside the NERDTree menu. You can switch windows by using ctrl+w then type :q to close NERDTree window so that you will be left with the window for editing your code.
After having opened a new file from the tree in a new window press ctrl-w p to switch back to the NERDTree and use it again to return to your previous window.
Have you tried this?
" Start NERDTree
autocmd VimEnter * NERDTree
" Jump to the main window.
autocmd VimEnter * wincmd p
It seems to me, based on your .vimrc
, that you are opening NERDTree. You just want to jump to the other window afterwards.
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