Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
like image 229
jmreicha Avatar asked Jul 06 '15 18:07

jmreicha


People also ask

How do you switch windows in NERDTree?

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

How do you hide NERDTree?

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.

How do I switch back to NERDTree?

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.


1 Answers

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.

like image 114
Gordonium Avatar answered Sep 20 '22 11:09

Gordonium