【问题标题】:Not an editor command :PluginInstall, vim in mac osx 10.12.6不是编辑器命令 :PluginInstall, vim in mac osx 10.12.6
【发布时间】:2018-04-08 17:15:45
【问题描述】:

我遇到了 vim 的下一个问题,我有一个 Mac OsX 10.12.6,我配置了 .vimrc,当我触摸 ESC 按钮时蚂蚁小费:PluginInstall,告诉我下一个错误:

E492: Not an editor command: PluginInstall

我按照这个页面的教程https://realpython.com/vim-and-python-a-match-made-in-heaven/但是,我认为有一个问题,因为它不能正常工作,因为我无法使用命令:PluginInstall安装任何插件 我已经安装了 MacVim,我的 .vimrc 是下一个:

set nocompatible              " required
filetype off                  " required

 set the runtime path to include Vundle and initialize
 set rtp+=~/.vim/bundle/Vundle.vim
 set splitbelow
 set splitright
 call vundle#begin()
 "split navigations
 nnoremap <C-J> <C-W><C-J>
 nnoremap <C-K> <C-W><C-K>
 nnoremap <C-L> <C-W><C-L>
 nnoremap <C-H> <C-W><C-H>
 " Enable folding
 set foldmethod=indent
 set foldlevel=99
 " Enable folding with the spacebar
 nnoremap <space> za
 " alternatively, pass a path where Vundle should install plugins
 "call vundle#begin('~/some/path/here')

 " let Vundle manage Vundle, required
 Plugin 'gmarik/Vundle.vim'
 Plugin 'tmhedberg/SimplyFold'
 Helptags

 let g:SimplyFold_docstring_preview=1
 " PEP8 indetantion
 au BufNewFile,BufRead *.py
    \ set tabstop=4
    \ set softtabstop=4
    \ set shiftwidth=4
    \ set textwidth=79
    \ set expandtab
    \ set autoindent
    \ set fileformat=unix
 " HTML, JS, CSS indentation
 au BufNewfile,BufRead *.js, *.html, *.css
    \ set tabstop=2
    \ set softtabstop=2
    \ set shiftwidth=2
 "Fix problem indentation PEP8
 Plugin 'vim-script/indentpython.vim'
 "Uneccesary whitespace
 au BufRead,BufNewfile *.py,*.pyw,*.c,*.h match BadWhitespace /\s\+$/
 " UTF8 support
 set encoding=utf-8
 "Autocomplete
 Bundle 'Valloric/YouCompleteMe'

 let g:ymc_autoclose_preview_window_after_completion=1
 map <leader>g :YcmCompleter GoToDefinitionElseDeclaration<CR>

 " python with virtualenv support

 py << EOF
 import os
 import sys
 if 'VIRTUAL_ENV' in os.environ:
     project_base_dir = os.environ['VIRTUAL_ENV']
     activate_this = os.path.join(project_base_dir, 'bin/activate_this.py')
     execfile(activate_this, dict(__file__=activate_this))
 EOF

 " Syntax Checkin/Highlighting
 Plugin 'vim-syntastic/syntastic'
 Plugin 'nvie/vim-flake8'
 let python_highlight_all=1
 syntax on

 "Color Shemes
 Plugin 'jnurmin/Zenburn'
 Plugin 'altercation/vim-colors-solarized'
 if has('gui_running')
     set background=dark
     colorscheme solarized
 else
     colorscheme zenburn
 endif
 call togglebg#map("<F5>")
 "File Browsing
 Plugin 'scrooloose/nerdtree'
 Plugin 'jistr/vim-nerdtree-tabs'
 let NERDTreeIgnore=['\.pyc$','\~$'] "Ignore files in NERDTree

 "SuperSearching
 Plugin 'kien/ctrlp.vim'
 "Line numering
 set nu
 "Git integration
 Plugin 'tpope/vim-fugitive'

 "Powerline
 Plugin 'Lokaltog/powerline', {'rtp': 'powerline/bindings/vim/'}

 "System clipboard
 set clipboard=unnamed
 "VIM in the shell
 set editing-mode vi

 " add all your plugins here (note older versions of Vundle
 " used Bundle instead of Plugin)

 " ...

 " All of your Plugins must be added before the following line
 call vundle#end()            " required
 filetype plugin indent on    " required

我尝试更改我的 .vimrc,但现在错误是下一个:

dmuino@Diegos-MacBook-Pro:~$ vi .vimrc
Error detected while processing /Users/dmuino/.vimrc:
line    4:
E518: Unknown option: the 
line    8:
E15: Invalid expression: /Users/dmuino/.vim/bundle/Vundle.vim)
E116: Invalid arguments for function vundle#begin
Error detected while processing function vundle#config#bundle[2]..<SNR>5_check_bundle_name:
line    1:
E121: Undefined variable: s:bundle_names
E116: Invalid arguments for function has_key(s:bundle_names, a:bundle.name)
E15: Invalid expression: has_key(s:bundle_names, a:bundle.name)
line   11:
E121: Undefined variable: s:bundle_names
line    1:
E121: Undefined variable: s:bundle_names
E116: Invalid arguments for function has_key(s:bundle_names, a:bundle.name)
E15: Invalid expression: has_key(s:bundle_names, a:bundle.name)
line   11:
E121: Undefined variable: s:bundle_names
Error detected while processing /Users/dmuino/.vimrc:
line   25:
E492: Not an editor command:  Helptags
Error detected while processing function vundle#config#bundle[2]..<SNR>5_check_bundle_name:
line    1:
E121: Undefined variable: s:bundle_names
E116: Invalid arguments for function has_key(s:bundle_names, a:bundle.name)
E15: Invalid expression: has_key(s:bundle_names, a:bundle.name)
line   11:
E121: Undefined variable: s:bundle_names
line    1:
E121: Undefined variable: s:bundle_names
E116: Invalid arguments for function has_key(s:bundle_names, a:bundle.name)
E15: Invalid expression: has_key(s:bundle_names, a:bundle.name)
line   11:
E121: Undefined variable: s:bundle_names
Error detected while processing /Users/dmuino/.vimrc:
line  109:
  File "<string>", line 1
    import os
    ^
IndentationError: unexpected indent
Press ENTER or type command to continue
 set nu
 "Git integration
 Plugin 'tpope/vim-fugitive'

 "Powerline
 Plugin 'Lokaltog/powerline', {'rtp': 'powerline/bindings/vim/'}

 "System clipboard
 set clipboard=unnamed
 "VIM in the shell
 set editing-mode vi

 " add all your plugins here (note older versions of Vundle
 " used Bundle instead of Plugin)

 " ...

 " All of your Plugins must be added before the following line
 call vundle#end()            " required
 filetype plugin indent on    " required

【问题讨论】:

  • PluginInstallVundle插件的命令,需要先安装配置。您已将 call vundle#begin 注释掉。取消注释并编辑路径。
  • 我把这个:call vundle#begin(/Users/dmuino/.vim/bundle/Vundle.vim) 但问题仍然存在

标签: macos vim


【解决方案1】:

你的插件管理器Vundle:PluginInstallvim-plug:PlugInstall可能有问题,下图是vim-plug:

您可以尝试通过这样做来安装vim-plug

curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

然后修改你的.vimrc:

call plug#begin('~/.vim/plugged')

查看示例以获取更多选项:https://github.com/junegunn/vim-plug#example

【讨论】:

  • 其实Vundle有一个PluginInstall命令,而vim-plug有一个PlugInstall命令(区别是Plugin而不是Plug
  • 我同时使用插件和插件,但不工作,你知道吗?
【解决方案2】:

文件的第 4 行必须是 COMMENT。 所以让它以"开始

代替

 set the runtime path to include Vundle and initialize

应该是的

"  set the runtime path to include Vundle and initialize

【讨论】:

    【解决方案3】:

    您是否错过了安装 Vundle 的步骤?

    此命令将 Vundle 安装到您主目录中的 .vim/bundle

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

    .vimrcset rtp+=~/.vim/bundle/Vundle.vim 中的第 5 行告诉 VIM 在哪里寻找 Vundle,之后第 8 行 call vundle#begin() 应该可以正常运行。

    请注意,第 4 行中还有一个语法错误,如 @Cosmic 的 answer mentions

    【讨论】:

      【解决方案4】:

      E492 用于解决 git 将 vundle 文件克隆到错误位置的路径问题。我想你必须提供绝对路径。 Vundle 插件还有很多其他 vim 无法处理的问题。最好是在学习和应用时编写自己的配置设置。

      【讨论】:

        【解决方案5】:

        由于您有 OSX,请尝试按照以下步骤操作

        删除你用自制软件安装的vim(别担心,我们稍后会安装)

        $ brew remove vim
        $ brew cleanup
        

        用这个自制命令安装 vim

        $ brew install macvim --with-override-system-vim
        

        检查你的 git 版本是否已经安装

        $ git version
        

        安装 vundle

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

        打开vim

        $ vim
        

        试试

        :PluginInstall
        

        【讨论】:

          猜你喜欢
          • 2015-07-13
          • 2014-08-02
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2013-03-20
          • 1970-01-01
          • 2021-01-09
          相关资源
          最近更新 更多