Vim启动错误(无效表达式)Debian

时间:2014-02-20 08:57:06

标签: vim debian

我在设置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

6 个答案:

答案 0 :(得分:28)

哦,天啊!我看到几个问题:

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开始,然后逐渐添加插件,这样您就会更加熟练并确定需求。

答案 1 :(得分:6)

对于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

答案 2 :(得分:3)

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

答案 3 :(得分:2)

我看到了这些类型的错误:

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设置,删除下载的文件,然后重试。

答案 4 :(得分:1)

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

  1. 更多.vimrc #prepare用于复制粘贴
  2. vi .vimrc #start,空白.vimrc
  3. 将原始.vimrc内容复制粘贴到空白.vimrc
  4. 完成

答案 5 :(得分:0)

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>//

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

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