【问题标题】:Vim startup errors (invalid expression) DebianVim 启动错误(无效表达式)Debian
【发布时间】:2014-02-20 08:57:06
【问题描述】:

我在设置 Vim 时遇到问题。首先,我在启动 Vim 时遇到了一堆错误,我得到了这些错误:

Error detected while processing /home/lee/.vimrc:
line    5:
E492: Not an editor command: generate helptags for everything in 'runtimepath'
Error detected while processing /home/lee/.vim/plugin/fuf.vim:
line   13:
***** L9 library must be installed! *****
Error detected while processing /home/lee/.vim/plugin/refactor.vim:
line   45:
E492: Not an editor command: ^M
line   53:
E492: Not an editor command: ^M
line   55:
E15: Invalid expression: ["auto", "const", "double", "float", "int", "short", "struct", "unsigned", "break", "continue", "else", "for", "long", "signed", "switch", "void", "case", "default", "enum", "goto", "register", "sizeof", "typedef", "volatile", "char", "do", "extern", "if", "return", "static", "union", "while", "asm", "dynamic_cast", "namespace", "reinterpret_cast", "try", "bool", "explicit", "new", "static_cast", "typeid", "catch", "false", "operator", "template", "typename", "class", "friend", "private", "this", "using", "const_cast", "inline", "public", "throw", "virtual", "delete", "mutable", "protected", "true", "wchar_t", "size_t"]^M
line   56:
E492: Not an editor command: ^M
line   58:
E15: Invalid expression: '\<\h\w*\>'^M
line   59:
E15: Invalid expression: '\s*[*&]*\s*'^M
line   60:
E121: Undefined variable: s:IdentifierPattern
E15: Invalid expression: s:IdentifierPattern . s:TypePostfixPattern^M
line   62:
E121: Undefined variable: s:TypeElementPattern
E15: Invalid expression: '\%(' . s:TypeElementPattern . '\%(' . s:TemplateParameterPattern . s:TypePostfixPattern . '\)*' . s:TypePostfixPattern . '\)\+'^M
line   64:
E15: Invalid expression: '\%(\s\+\n*\s*\|\n\+\|\s*\n*\s\+\)'^M
line   65:
E121: Undefined variable: s:TypeIdentifierPattern
E15: Invalid expression: s:TypeIdentifierPattern . s:MissableSeperatorPattern . s:IdentifierPattern . '\%\(\[\d*\]\)*'^M
line   66:
E121: Undefined variable: s:TypeIdentifierPattern
E15: Invalid expression: '^\s*\%(' . s:TypeIdentifierPattern . s:SeperatorPattern. '\|' . s:IdentifierPattern . '::\)\+' ^M
line   67:
E121: Undefined variable: s:VariableDeclarationPattern
E15: Invalid expression: '(' .  s:MissableSeperatorPattern . '\%(' . s:VariableDeclarationPattern . '\%(\s*,' . s:MissableSeperatorPattern . s:VariableDeclarationPattern . '\)*\)*\s*)'^M
line   68:
E121: Undefined variable: s:FunctionPerfixPattern
E15: Invalid expression: s:FunctionPerfixPattern . s:MissableSeperatorPattern . s:IdentifierPattern . s:MissableSeperatorPattern . s:ParameterListPattern . '[^(){;]*'^M
line   69:
E121: Undefined variable: s:FunctionPattern
E15: Invalid expression: s:FunctionPattern . s:MissableSeperatorPattern . '\%(;\)\@='^M
line   70:
E121: Undefined variable: s:FunctionPattern
E15: Invalid expression: s:FunctionPattern . s:MissableSeperatorPattern . '\%({\)\@='^M
line   71:
E492: Not an editor command: ^M
line   72:
E488: Trailing characters
line  114:
E492: Not an editor command: ^M
line  115:
E488: Trailing characters
line  182:
E492: Not an editor command: ^M
line  183:
E488: Trailing characters
line  220:
E492: Not an editor command: ^M
line  221:
E488: Trailing characters
line  240:
E492: Not an editor command: ^M
line  241:
E488: Trailing characters
line  285:
E492: Not an editor command: ^M
line  286:
E488: Trailing characters
line  359:
E492: Not an editor command: ^M
line  360:
E488: Trailing characters
line  372:
E492: Not an editor command: ^M
line  374:
E488: Trailing characters
line  411:
E492: Not an editor command: ^M
line  412:
E488: Trailing characters
line  424:
E492: Not an editor command: ^M
line  425:
E488: Trailing characters
line  432:
E492: Not an editor command: ^M
line  433:
E488: Trailing characters
Press ENTER or type command to continue

另外,当我尝试运行:helptags ~/.vim/doc 时,它根本不会加载。它只是显示一个空白的编辑器屏幕。

非常感谢您的帮助,我已经在网上搜索了解决方案,但我无法修复它。我真的很想开始使用 Vim。谢谢!

编辑:我添加了我的 .vimrc

set nocompatible
call pathogen#infect()
execute pathogen#infect()
call pathogen#helptags()
generate helptags for everything in 'runtimepath'
syntax on
filetype plugin indent on

【问题讨论】:

    标签: vim debian


    【解决方案1】:

    linux 中的简单选项。 转到捆绑文件夹~/.vim/bundle 或特定包目录执行find . | xargs dos2unix

    【讨论】:

    • 谢谢,这对于跨 windows/wsl/*nix 等的翻译文件非常有用。
    【解决方案2】:

    天哪!我看到了几个问题:

    E492: Not an editor command: generate helptags for everything in 'runtimepath'
    

    你必须有一个以generate helptags ...开头的行(你的~/.vimrc?);它应该是一个注释:在该行前添加一个 "


    ***** L9 library must be installed! *****
    

    FuzzyFinder 插件需要另一个插件;您可以通过L9 - Vim-script library 获得它。


    Error detected while processing /home/lee/.vim/plugin/refactor.vim:
    line   45:
    E492: Not an editor command: ^M
    

    这是由在 Linux 上使用时具有 Windows 样式 CR-LF 行结尾的 Vimscript 文件引起的。在 Vim 中打开相应的文件并通过

    将它们转换为 Unix 风格的结尾
    :w ++ff=unix
    

    我希望你会在这些之后开始看到光明。指向完整 Vim 配置的链接将有助于进一步诊断。 如果您是 Vim 新手,建议您从精益的 .vimrc 开始,然后逐渐添加插件,随着您越来越熟练并确定需求。

    【讨论】:

    • 嗯。我认为我们应该设置 2 小时轮班:你做 2 小时,我做 2 小时,FDinoff 做 2 小时,Kent 做 2 小时……
    • @romainl:有趣的是,您的回答如何反映了我的情况!我想没有人会抱怨没有在 Stack Overflow 上获得与 Vim 一样物有所值的支持 :-)
    • @IngoKarkat 我添加了我的 .vimrc 现在你可以看看吗?
    • 您仍然需要注释掉/删除第 5 行;除此之外,它很好。你在其他问题上取得进展了吗?!
    • @IngoKarkat 是的,我没有任何错误了,但是当我写 :helptags ~/.vim/doc 时,什么也没有出现!我会让你的评论成为解决方案
    【解决方案3】:

    我看到这些类型的错误:

    Error detected while processing ~/.vim/plugin/<some_plugin_giving_you_error>:
    line   45:
    E492: Not an editor command: ^M
    

    .gitconfig 具有与 Windows 相关的 [core] 设置但在 Linux 机器上使用时。然后,当通过 Vim 插件管理器或手动下载插件时,这些错误开始出现。

    所以我建议检查你的 Git 设置,删除下载的文件,然后重试。

    【讨论】:

    • 我将我的设置从 Windows 复制到 WSL 并点击它。在 WSL 中,您的 ~/.gitconfig 应该包含 [core] > autocrlf = false
    • @Scott Wade 你的回答太精彩了,谢谢!我不知道哪个白痴在我的机器上设置了autocrlf = true(我是唯一的用户哈哈),但我知道发生了一些可疑的事情。因为我从 GitHub 克隆的几十个 Vim 插件的所有源文件根本不可能在默认情况下都有 CRLF 结尾。
    【解决方案4】:

    对于E492: Not an editor command: ^M 部分,我实际上遇到了同样的问题,但上述答案没有帮助。 所以我找到了这个,它对我有用:

    对于 Cygwin(我使用):从包安装程序安装 dos2unix

    对于 Ubuntu/Debian:

    sudo apt-get install tofrodos; sudo ln -s /usr/bin/fromdos /usr/bin/dos2unix
    

    对于 CentOS、Fedora、...:

    sudo yum install dos2unix
    

    那就这样用吧:

    dos2unix ~/.vimrc
    

    这应该清除文件中的所有 CRLF

    【讨论】:

    • 你也可以在vim和:set ff=unix中打开.vimrc文件,然后保存,将所有文件结尾转换为unix风格。
    • 在 Windows 上工作时,确保还编辑由 .vimrc 本身加载的任何脚本的行尾。似乎很明显,但我花了一段时间才意识到错误不再来自我的.vimrc...
    【解决方案5】:

    没有任何工具的简单方法涉及:

    1. more .vimrc #prepare for the copy paste
    2. vi .vimrc #以空白 .vimrc 开始
    3. 复制粘贴原始.vimrc内容到空白.vimrc
    4. 完成

    【讨论】:

      【解决方案6】:
      Error detected while processing /home/lee/.vimrc:
      line    5:
      E492: Not an editor command: generate helptags for everything in 'runtimepath'
      

      该行没有注释

      Error detected while processing /home/lee/.vim/plugin/fuf.vim:
      line   13:
      ***** L9 library must be installed! *****
      

      FuzzyFinder 需要 L9 库,但没有找到。

      Error detected while processing /home/lee/.vim/plugin/refactor.vim:
      line   45:
      E492: Not an editor command: ^M
      

      在 Linux 上,Vim 不喜欢 Windows 行尾,而且你似乎有很多。

      line   55:
      E15: Invalid expression: ["auto", "const", "double", "float", "int", "short", "struct", "unsigned", "break", "continue", "else", "for", "long", "signed", "switch", "void", "case", "default", "enum", "goto", "register", "sizeof", "typedef", "volatile", "char", "do", "extern", "if", "return", "static", "union", "while", "asm", "dynamic_cast", "namespace", "reinterpret_cast", "try", "bool", "explicit", "new", "static_cast", "typeid", "catch", "false", "operator", "template", "typename", "class", "friend", "private", "this", "using", "const_cast", "inline", "public", "throw", "virtual", "delete", "mutable", "protected", "true", "wchar_t", "size_t"]^M
      

      同上,后面的^M是问题所在。

      line   58:
      E15: Invalid expression: '\<\h\w*\>'^M
      

      等等……

      这个命令

      :%s/<C-v><CR>//
      

      应该减少错误的数量。 &lt;C-v&gt;&lt;CR&gt; 表示“按 Ctrl+V,然后按 Enter 键”。

      请告诉我们您的~/.vimrc,以便我们进一步帮助您。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2014-11-05
        • 1970-01-01
        • 2014-05-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多