2

I want to keep NERDTree always available at left (since vim starts).

NERDTree documentations has nothing relating to this and I don't think it has such inbuilt feature.

Well I tried setting by my own and did this:

autocmd VimEnter * NERDTree

But this seems buggy, the annoying things I found are:

  1. At startup the cursor is focused at NERDTree, it should be at editor window instead.
  2. When closing (with :q) the editor window closes, but the NERDTree is focused (I want to quit immediately, no wait!)

Do you have any better idea than this?

4

1 回答 1

0

对于 1.,添加返回上一个窗口的指令:

autocmd VimEnter * execute 'NERDTree' | wincmd p

对于 2.,您可以只使用:qa; 要自动执行此操作,您必须定义一个 autocmd 来检查最后剩余的窗口是否来自 NERDTree,如下所示(未经测试):

autocmd WinEnter * if winnr('$') == 1 && exists("t:NERDTreeBufName") && bufwinnr(t:NERDTreeBufName) == 1 | quit | endif
于 2012-09-23T15:16:54.707 回答