Vim 错误 E492 - 不是编辑器命令:PluginInstall

Vim Error E492 - Not an editor command: PluginInstall

我正在尝试在我的 Mac 上安装 Vundlevim。我按照下面的link得到了Vundle。我还配置了我的 .vimrc 文件。但是当我尝试 PluginInstall 时,出现以下错误。

E492: Not an editor command: PluginInstall

我的 .vimrc 包含以下内容:

  1 set nocompatible    "
    ompatible-completely-useless
  2
  3 " https://github.com/gmarik/Vundle.vim
  4 filetype off                  " required
  5
  6 " set the runtime path to include Vundle and initialize
  7 set rtp+=~/.vim/bundle/Vundle.vim
  8 call vundle#begin()
  9 " alternatively, pass a path where Vundle should install plugins
 10 "call vundle#begin('~/some/path/here')
 11
 12 " let Vundle manage Vundle, required
 13 Plugin 'gmarik/Vundle.vim'
 14
 15 " All of your Plugins must be added before the following line
 16 call vundle#end()            " required
 17 filetype plugin indent on    " required

我的 vim 目录:

Username-MacBook-Pro:bundle u1$ pwd
/Users/u1/.vim/bundle
Username-MacBook-Pro:bundle u1$ ls
Vundle.vim

我还检查了 this Whosebug post。但这并没有解决我的问题。为什么会抛出这样的错误,我怎样才能找到我的问题所在。

我必须将 Vundle 安装到 Plugin 目录而不是 Bundle。它解决了这个问题。

git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/plugin/Vundle.vim

您可以检查 :version

的输出
   system vimrc file: "/etc/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"

注意你正在使用哪个 vimrc 文件,假设你正在配置 $HOME/vimrc,但是 vim 正在读取 $HOME/.vimrc(文件名没有点)

这件事发生在我身上。

希望对您有所帮助。

如前所述here,我需要像这样设置 Vundle:

$ git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim

后来,错误得到解决。顺便说一句,我在 FreeBSD 10.3-STABLE 机器上,而不是 macOS

这可能是行尾字符的结果,windows 的 CRLF 和 linux 的 LF。
更改您的行结尾。
如果在你的 ~/.vimrc 文件中的 unix 上:

:set fileformat=unix :w