1

Currently I have NERDTree opening by default when I edit a file that is not a git commit message using this command:

autocmd VimEnter * if &filetype !=# 'gitcommit' | NERDTree | endif

Only issue is that when the file opens, NERDTree is the default buffer, which is very annoying. What can I add to my vimrc file so that when I open a file, that file is the focused buffer, and not NERDTree?

4

2 回答 2

5

You can try this command to switch to the previous window after NERDTree is opened.

autocmd VimEnter * if &filetype !=# 'gitcommit' | NERDTree | wincmd p | endif
于 2013-09-10T18:39:45.867 回答
2

nerdtree tabs will handle that for you automatically.

let g:nerdtree_tabs_open_on_console_startup=1
let g:nerdtree_tabs_open_on_gui_startup=1

It will also select the right buffer for you.

于 2013-09-10T18:40:58.410 回答