:version
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Oct 21 2017 01:21:26)
MacOS X (unix) version
Included patches: 1-1207
My .vimrc has
:nmap ,s :source ~/.vimrc I tried that right after installing the mccvim just now, and got these errors:
Error detected while processing /Users/jk/.vimrc:
line 18:
E15: Invalid expression: 0^M
line 20:
E15: Invalid expression: has("gui_running") && has("menu")^M
line 99:
E15: Invalid expression: 0^M
line 101:
E15: Invalid expression: has("gui_running") && has("menu")^M
line 203:
E15: Invalid expression: 0^M
line 205:
E15: Invalid expression: has("gui_running") && has("menu")^M
I don't find '0^M' in the .vimrc at all.
Everything was fine until the update; what happened?
Unix-like systems (including OSX) and Windows have different conventions on what "end of line" should look like. Unix uses LF (ASCII 0A, also represented as ^J); Windows uses CRLF (ASCII 0D0A, also represented as ^M^J.
Vim can use both kinds of files, depending on its fileformats (ffs) setting. set ffs=unix,dos will make Vim try to guess how the file is formatted, and sets the fileformat (ff) accordingly. However, if ffs is set to just unix, then Vim will not try to guess, ff gets set to unix; under this setting, if the file was saved for Windows (i.e. has CRLF line endings), LF will be interpreted as newline, and CR will be presented as ^M. Vimscript doesn't know what to do with ^M, and complains.
To convert your file to Unix format (the recommended action, since your file is foreign to the operating system you're using), run these commands:
:e ++ff=dos .vimrc
:setl ff=unix
:w
I'm trying to install Syntastic for Vim using Cygwin. After completing step 2.1 and the cloning part of step 2.2 in the installation guide of Syntastic, I find that now when I run vim I get the following errors:
Error detected while processing /home/rjw08/.vim/bundle/syntastic/plugin/syntastic/autoloclist.vim:
line 1:
E15: Invalid expression: exists("g:loaded_syntastic_notifier_autoloclist") || !exists("g:loaded_syntastic_plugin")^M
line 39:
E171: Missing :endif
Error detected while processing /home/rjw08/.vim/bundle/syntastic/plugin/syntastic/balloons.vim:
line 1:
E15: Invalid expression: exists("g:loaded_syntastic_notifier_balloons") || !exists("g:loaded_syntastic_plugin")^M
line 67:
E171: Missing :endif
Error detected while processing /home/rjw08/.vim/bundle/syntastic/plugin/syntastic/checker.vim:
line 1:
E15: Invalid expression: exists("g:loaded_syntastic_checker") || !exists("g:loaded_syntastic_plugin")^M
There were a few more errors, but they follow this basic format. From what I understand, file endings in the listed files are incorrect (i.e. ^M). However when I open these files in Vim, there does not seem to be any ^M endings to delete.
How do I fix this problem?
Load the file into vim, then :set fileformat=unix and :wq should fix it.
PS: you don't see the ^Ms because vim thinks it is a dos file (it probably says [dos] in the status bar after loading).
This command will transform every file to a unix file in the ~/.vim/bundle directory.
find ~/.vim/bundle -type f -follow -print|xargs dos2unix
I'm having issues setting up Vim. Firstly I'm having a bunch of errors when start up Vim, I get these errors:
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
Also, when I try to run :helptags ~/.vim/doc it doesn't load at all. It just shows a blank editor screen.
I would appreciate your help, I've searched the web for solutions but I've been unable to fix it. I really want to start using Vim. Thank you!
EDIT: I added my .vimrc
set nocompatible
call pathogen#infect()
execute pathogen#infect()
call pathogen#helptags()
generate helptags for everything in 'runtimepath'
syntax on
filetype plugin indent on
Oh my gosh! I see several issues:
E492: Not an editor command: generate helptags for everything in 'runtimepath'
You must have a line starting with generate helptags ... somewhere (your ~/.vimrc?); it should be a comment: Prepend a " to the line.
***** L9 library must be installed! *****
The FuzzyFinder plugin requires another plugin; you can get it at L9 - Vim-script library.
Error detected while processing /home/lee/.vim/plugin/refactor.vim:
line 45:
E492: Not an editor command: ^M
That's caused by Vimscript files that have Windows-style CR-LF line endings when used on Linux. Open the corresponding file(s) in Vim and convert them to Unix-style endings via
:w ++ff=unix
I hope you'll start to see the light after these. A link to your full Vim config would be helpful to further diagnose this. If you're new to Vim, it's recommended to start with a lean .vimrc, and only gradually add plugins, as you become more proficient and identify the needs.
For the E492: Not an editor command: ^M part, I actually got the same problem but the above answers didn't help.
So I found this and it works for me:
For Cygwin (which I use): install dos2unix from the package installer
For Ubuntu/Debian:
sudo apt-get install tofrodos; sudo ln -s /usr/bin/fromdos /usr/bin/dos2unix
For CentOS, Fedora, ...:
sudo yum install dos2unix
Then use it this way:
dos2unix ~/.vimrc
That should clean all CRLF from the file
I see these types of errors:
Error detected while processing ~/.vim/plugin/<some_plugin_giving_you_error>:
line 45:
E492: Not an editor command: ^M
when a .gitconfig has Windows relevant [core] settings but used on a Linux box. Then when a plugin is downloaded by either a Vim plugin manager or manually, these errors start showing up.
So I would suggest checking your Git settings, delete the downloaded files, and try again.
Simple option in linux.
Goto the bundle folder ~/.vim/bundle or the specific package dir execute find . | xargs dos2unix.
the simple way without any tools involve:
more .vimrc #prepare for the copy paste
vi .vimrc #start with a blank .vimrc
copy paste the original .vimrc content to the blank .vimrc
done
Error detected while processing /home/lee/.vimrc:
line 5:
E492: Not an editor command: generate helptags for everything in 'runtimepath'
That line is not commented
Error detected while processing /home/lee/.vim/plugin/fuf.vim:
line 13:
***** L9 library must be installed! *****
FuzzyFinder needs the L9 library but it didn't find it.
Error detected while processing /home/lee/.vim/plugin/refactor.vim:
line 45:
E492: Not an editor command: ^M
On Linux, Vim doesn't like Windows line endings and you seem to have a lot of them.
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
Same as above, the trailing ^M is the problem.
line 58:
E15: Invalid expression: '\<\h\w*\>'^M
And so on…
This command
:%s/<C-v><CR>//
should reduce the number of errors. <C-v><CR> means "hit Ctrl+V, then hit the Enter key".
Please show us your ~/.vimrc so that we can help you further.
OS: CentOS 5.7
I am trying to get both gVim/Vim have syntax highlight for a new file type. So far I did:
Create syntax file at ~/.vim/ftdetect/foo.vim.
Using Vim can automatically detect the new file type and enable syntax highlighting. $ vim myfile.foo
But gVim doesn't have syntax highlighting.
I tried to add this line in ~/.gvimrc:
au BufRead,BufNewFile *.foo set filetype=foo
But it looks like gVim didn't load ~/.vim/ftdetect/foo.vim at all. How should I configure gVim?
Move the foo.vim to ~/.vim/syntax/ doesn't work for both Vim/gVim. They can't auto detect ~/.vim/syntax folder.
Below are the scriptnames list (+ sign to indicate extra files loaded by gVim), gVim does load foo.vim, but not sure how to figure out what's overwrite the foo.vim settings. Since using :set syntax=foo in gVim won't work either.
:au BufRead,BufNewFile *.foo shows no detection rule for both vim/gVim. So the Vim just magically works...
This is the syntax rule. Is the version checking in the rule file causing gVim can't recognize the *.foo file?
[vim:scriptnames]
1: /etc/vimrc
2: /usr/share/vim/vim70/syntax/syntax.vim
3: /usr/share/vim/vim70/syntax/synload.vim
4: /usr/share/vim/vim70/syntax/syncolor.vim
5: /usr/share/vim/vim70/filetype.vim
6: /home/myusername/.vim/ftdetect/foo.vim
7: /home/myusername/.vimrc
8: /usr/share/vim/vim70/plugin/getscript.vim
9: /usr/share/vim/vim70/plugin/gzip.vim
10: /usr/share/vim/vim70/plugin/matchparen.vim
11: /usr/share/vim/vim70/plugin/netrwPlugin.vim
12: /usr/share/vim/vim70/plugin/rrhelper.vim
13: /usr/share/vim/vim70/plugin/spellfile.vim
14: /usr/share/vim/vim70/plugin/tarPlugin.vim
15: /usr/share/vim/vim70/plugin/tohtml.vim
16: /usr/share/vim/vim70/plugin/vimballPlugin.vim
17: /usr/share/vim/vim70/plugin/zipPlugin.vim
18: /usr/share/vim/vim70/scripts.vim
[GVIM :scriptnames]
1: /etc/vimrc
2: /usr/share/vim/vim70/syntax/syntax.vim
3: /usr/share/vim/vim70/syntax/synload.vim
4: /usr/share/vim/vim70/syntax/syncolor.vim
5: /usr/share/vim/vim70/filetype.vim
6: /home/myusername/.vim/ftdetect/foo.vim
+ 7: /usr/share/vim/vim70/menu.vim
+ 8: /usr/share/vim/vim70/autoload/paste.vim
9: /home/myusername/.vimrc
10: /usr/share/vim/vim70/plugin/getscript.vim
11: /usr/share/vim/vim70/plugin/gzip.vim
12: /usr/share/vim/vim70/plugin/matchparen.vim
13: /usr/share/vim/vim70/plugin/netrwPlugin.vim
14: /usr/share/vim/vim70/plugin/rrhelper.vim
15: /usr/share/vim/vim70/plugin/spellfile.vim
16: /usr/share/vim/vim70/plugin/tarPlugin.vim
17: /usr/share/vim/vim70/plugin/tohtml.vim
18: /usr/share/vim/vim70/plugin/vimballPlugin.vim
19: /usr/share/vim/vim70/plugin/zipPlugin.vim
+ 20: /home/myusername/.gvimrc
+ 21: /usr/share/vim/vim70/colors/torte.vim
22: /usr/share/vim/vim70/scripts.vim
What gets loaded should be identical for Vim and gVim (unless you do crazy stuff like manipulating the 'runtimepath' in your .gvimrc); you can check with :scriptnames whether your syntax detection script got loaded (and then, also the actual syntax/foo.vim syntax script).
Also, :au BufRead,BufNewFile *.foo should list your detection rule.
Does (other) syntax highlighting work in gVim?! If it doesn't, you have a general problem there.