Make NERDtree not be the default window when VIM starts?
Asked Answered
D

2

12

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
Dawndawna answered 6/7, 2015 at 18:30 Comment(1)
@Floegipoky I am updating with the relevant parts of my vimrc (mostly pulled from the github project). I have experimented with your config but I don't think it quite does what I am looking for? Unless I don't have it in there correctly. 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.Dawndawna
T
20

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.

Thoron answered 6/7, 2015 at 20:3 Comment(0)
R
2

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.

Retarder answered 25/6, 2016 at 21:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.