jmreicha
jmreicha

Reputation: 3344

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

Upvotes: 12

Views: 5468

Answers (2)

JackHasaKeyboard
JackHasaKeyboard

Reputation: 1665

What you can do is just change the active pane.

autocmd VimEnter * wincmd w

This is the equivalent of hitting CTRL+W W, stick it in your .vimrc after where you call NERDTree and it'll stick you in the next pane on startup.

Upvotes: 2

Gordonium
Gordonium

Reputation: 3487

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.

Upvotes: 20

Related Questions