I was using an older version of vim on Windows, then I switched to a Mac computer and MacVim and brought over my imap files and vimrc, but the imaps no longer work. When I open a file it gives me an "Error detected while processing .. etc. ftplugins/html_imaps.vim" for example:

line 1:

E15: Invalid expression: ";"^M 

The line in question in the imap file says:

let maplocalleader=";"

Is there a reason this doesn't work anymore? It was also giving me an error on each empty line. I deleted the empty lines so those errors went away, but I haven't been able to do anything about maplocalleader line.

Thanks for any suggestions.

有帮助吗?

解决方案

Because your .vimrc file came from a Windows machine, it has \r\n line endings, so you need to get rid of the \r (which shows up as ^M). It looks like my Mac doesn't have dos2unix, so you'll probably want to just use tr:

tr -d '\r' <~/.vimrc >tmp
mv tmp ~/.vimrc 

Or from within vim itself:

:%s/\r//g

On the off-chance you have \rs you actually want to keep,

:%s/\r$

With the implied //

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top