如何在 Windows 环境中安装 Vim 插件

How to Install Vim Plugins in a Windows Environment

我刚刚开始使用 Vim 并使用 http://vimawesome.com/ 推荐的一些插件设置环境。我下载并放置 plug.vim 到 C:\Program Files\Vim\vim74\autoloadC:\Program Files\Vim\vimfiles\plugin 中,我将 git master 分支 nerdtree-master 重命名为 nerdtree。在 _vimrc 文件中,我把

Plug 'scroloose/nerdtree

Plug 'nerdtree

这些命令都不起作用。我收到此错误:

Error detected while processing C:\Program Files\Vim\_vimrc:

line    7:

E492: Not an editor command: Plug 'nerdtree'

Error detected while processing
C:\Program Files\Vim\vim74\plugin\nerdtree\lib\nerdtree\path.vim:

我终于发现我忘了用

换行 Plug 'nerdtree'
call plug#begin('~/.vim/plugged')
Plug 'nerdtree'
call plug#end()

尽管 .vim 是 Linux 路径,但 Vim 或 Vim-Plug 能够识别该路径。然后我收到必须安装 Git 的错误消息。我已经安装了Git,所以我只是在系统环境变量%PATH%中添加了C:\Program Files\Git\bin。重新启动后 Vim 我输入了

:PlugInstall

在 Vim 编辑器中。

vim-plug 插件管理器开始工作并打印:

- Finishing ... Done!
x nerdtree:
    Cloning into 'C:\Users\labbedz7\.vim\plugged\nerdtree'...
    remote: Invalid username or password.
    fatal: Authentication failed for 'https://git::@github.com/vim-scripts/nerdtree.git/'

现在,Git 没有 "authenticate",因为 Plug 'String' 中的字符串指的是 GitHub URL 路径:http://github.com/String。通过更改为实际路径:scrooloose/nerdtree 我能够再次 运行 :PlugInstall

call plug#begin('~/.vim/plugged')
Plug 'scrooloose/nerdtree'
call plug#end()

这导致:

Updated. Elapsed time: 5.706874 sec.
[=]

- Finishing ... Done!
- nerdtree: Checking connectivity... done

然后我将这些行添加到 _vimrc:

autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif

Nerdtree 现在 运行宁!它从 Windows\System32 开始,加载有点慢,但它是 运行ning.