updated mccvim, now cannot source $HOME/.vimrc - vim

: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

Related

listchars causing E474: Invalid argument in recent versions of vim

The snippet below has been in my vimrc for quite some time, recently (in the latest versions of vim) I am getting an error in the forth line:
set listchars=tab:▸\ ,trail:◇,extends:»,precedes:«,eol:¬ " show tabs et. al.
I have not made any changes to my vimrc file and yet now I am getting this error:
Error detected while processing $HOME/.vim/rcfiles/editing:
line 11:
E474: Invalid argument: listchars=tab:�~V�\ ,trail:�~W~G,extends:»,precedes:«,eol:¬
line 11 is the 4th line in the snippet.
set list " show invisibles
set listchars=tab:>\ ,trail:-,extends:>,precedes:<,eol:$ " show tabs et. al.
if v:version >= 703
set listchars=tab:▸\ ,trail:◇,extends:»,precedes:«,eol:¬ " show tabs et. al.
if (&termencoding ==# 'utf-8' || &encoding ==# 'utf-8')
let &listchars="tab:\u21e5 ,trail:\u2423,extends:\u21c9,precedes:\u21c7,nbsp:\u00b7,eol:\u00ac"
let &listchars="tab:\u25b8 ,trail:\u25c7,extends:\u00bb,precedes:\u00ab,nbsp:\u00b7,eol:\u00ac"
endif
I haven't yet tried to go back to older versions where it works but I know that the error is thrown in version 8.0.1453 on one machine and version 8.2.2100 on another.
Oddly, if I type (or copy and paste) this line into vim, it is accepted with no problem, but in my vimrc I get an error on startup.
Any ideas?

Vimscript Operator-Pending Mappings yields "Trailing characters" error

I am trying to reproduce the example in chapter 15 of Steve Losh's "Learn Vimscript the Hard Way" (http://learnvimscriptthehardway.stevelosh.com/chapters/15.html), in the section called "Changing the Start."
First, I start vim with the following command:
vim -u NONE foo
to ensure that no plugins are loaded.
Next I type
print foo(bar)
in the buffer and then enter
:onoremap in( :<c-u>normal! f(vi(<cr>
Finally, I place the cursor over the "p" in "print" and enter cin(. The status line displays:
:<c-u>normal! f(vi(<cr>
with a blinking cursor at the end. I hit enter and the status line then displays:
E488: Trailing characters
The expected outcome, according to the book, is that vim will delete the contents of the parentheses and place you in insert mode between them.
Here is the version info:
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled May 2 2017 03:55:34)
MacOS X (unix) version
Included patches: 1-596
Compiled by Homebrew
TL;DR: use vim -u DEFAULTS foo instead.
That should keep Vim in 'nocompatible' mode, which is needed for <Key> codes to be recognized in mappings.
The symptoms you describe are consistent to having < included in 'cpoptions', which is documented to:
Disable the recognition of special key codes in <> form in mappings, abbreviations, and the "to" part of menu commands. For example, the command :map X <Tab> results in X being mapped to "<Tab>" (5 characters) when < is included; but "^I" (^I is a real <Tab>) when < is excluded.
That is consistent with you getting the literal result of your mapping in your command-line, without proper expansion of the <c-u> and <cr> key codes.
The defaults for 'cpoptions' are:
Vim default: "aABceFs",
Vi default: all flags
So this means < (along with all other flags) will be included by default in Vi mode, which is triggered when 'compatible' is set (or, perhaps more accurately, when 'nocompatible' is not set.)
It turns out that when you use -u NONE in your command-line starting Vim, it will start in 'compatible' mode.
You can use instead -u DEFAULTS, which is quite similar to -u NONE, but it will still load the defaults.vim script shipped with Vim runtime, which will among other things set 'nocompatible'.
From the docs:
When -u DEFAULTS (all uppercase) is passed, this has the same effect as -u NONE, but the defaults.vim script is loaded, which will also set 'nocompatible'.
Using the -u argument with another argument than DEFAULTS has the side effect that the 'compatible' option will be on by default. This can have unexpected effects.

Syntastic installation issue: ^M file endings

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

Vim startup errors (invalid expression) Debian

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.

Having an issue with <Leader> key and plugin (particularly EasyMotion)

So I am really new to VIM but was attempting to add some plugin's one of which is EasyMotion.
According to the vid tutorials at NetPlus, and Vim's Wiki Plugin Page, after dropping the plugin's .vim file in the plugins direction (on Windows) I should be able to initiate the EasyMotion plugin by hitting (from within a loaded file):
<Leader><Leader>w"
And according to the VIM documentation, Leader is set to the mapleader variable which is by default "\" unless change. I haven't changed it but hitting "\" does nothing but beep (windows error bell).
I did try even mapping:
let mapleader = ","
let g:mapleader = ","
and nothing changed.
UPDATE
I came across these errros when I accidently tried loading my _vimrc file by Vim (right clicked on file and chose to open with Vim) -> I think this might give some insight, but I haven't a clue why:
ERROR
Error detected while processing d:\Program Files (x86)\Vim\vimfiles\plugin\
EasyMotion.vim:
line 24:
E117: Unknown function: EasyMotion#InitOptions
line 39:
E121: Undefined variable: g:EasyMotion_hl_group_target
E116: Invalid arguments for function EasyMotion#InitHL
line 40:
E121: Undefined variable: g:EasyMotion_hl_group_shade
E116: Invalid arguments for function EasyMotion#InitHL
line 69:
E117: Unknown function: EasyMotion#InitMappings
I don't use the aforementioned plugin, so cannot help with it specifically, but as far as the other part goes, you can see what your leader is mapped by
:echo g:mapleader
Vim plugins are usually (if you're not using some plugin to manage plugins, like Pathogen or Vim-Addon-Manager) saved either in $VIM\plugins (bad), or in $VIMFILES\plugins (good), on Windows. If you're on unix, just replace \ with /.
You can also find out where your $VIM, $VIMFILES ... directories are by echoing them ... :echo $VIMFILES.
One more thing about mapleader. It is not dynamic - that is, once the mapping is defined with
<leader>some_key
and you change the leader variable, it does not redefine the mapping. So your leader has to change (for example, in your vimrc) before the actual mapping that is using it happens.
The answer came out to be that I had not added the autoload .vim file to the autoload directory. This was why I was getting the specific errors.

Resources