Make NERDtree not be the default window when VIM starts?

梦想与她 提交于 2019-12-05 20:32:16

问题


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:


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.




回答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.



来源:https://stackoverflow.com/questions/31253080/make-nerdtree-not-be-the-default-window-when-vim-starts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!