如何将NERDTree添加到我的.vimrc?
[好,以前的版本有点简洁,但是您要寻找的答案是将下面的行添加到~/.vimrc
文件中。它告诉Vim您想要设置一个命令来在Vim启动时运行,但是由于它依赖于要加载的各种插件,因此您不希望在所有初始化完成后运行它:
autocmd VimEnter * NERDTree
我只希望在不带文件参数的情况下启动vim时才看到NERDTree,所以我将其添加到了.vimrc中。
autocmd VimEnter * if !argc() | NERDTree | endif
您是在Windows还是UNIX系统上?
[如果您使用的是Unix系统,则将插件放入~/.vim/plugin
。这是我的插件目录的样子:
每NERDTree instructions,您只能使用pathogen.vim。通过以下方式安装:
mkdir -p ~/.vim/autoload ~/.vim/bundle; \ curl -Sso ~/.vim/autoload/pathogen.vim \ https://raw.github.com/tpope/vim-pathogen/master/autoload/pathogen.vim
将此添加到您的.vimrc:
这里的答案有一个小问题。
如果调用vim --noplugin
或使用使用--noplugin
模式的脚本,例如vimpager,将导致此错误:
Error detected while processing VimEnter Auto commands for "*":
E492: Not an editor command: NERDTree
" NERD Tree
nmap <silent> <special> <F2> :NERDTreeToggle<RETURN>