Search code examples
vimvim-pluginnerdtree

Make NERDtree not be the default window when VIM starts?


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

Solution

  • 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.