我最近安装了cygwin (因为我被限制在Windows操作系统上),并希望在其中使用Vim。一切都安装好了,我可以很容易地访问vim,并可以修改.vimrc等。从上一篇文章中,我了解到我的插件必须在Windows操作系统的vimfiles中,并且已经这样做了。但是,现在当我尝试验证病原体时,我得到一个错误,声明:
E492: Not an editor command: ^M (this repeats a couple times)
E15: Invalid expression: exists("g:loaded_pathogen") || &cp^M
E117: Unknown function: pathogen#infect我的.virmc (同样是非常基本的,只是尝试启动所有东西)
version 6.0
if &cp | set nocp | endif
let s:cpo_save=$cpo
enter code here
set cpo&vim
map! <C-Home> <C-Home>
map! <C-End> <C-End>
let &cpo=s:cpo_save
unlet s:cpo_save
set autoindent
set ff=unix
set background=dark
set backspace=2
set fileencodings=ucs-bom,utf-8,default,latin1
set helplang=en
set history=50
set laststatus=2
set ruler
set shelltemp
set viminfo='100,<50,s10,h
set window=55
" vim: set ft=vim :
call pathogen#infect()
syntax on
filetype plugin indent on致以敬意,
发布于 2012-12-20 06:03:35
在shell中,尝试执行以下命令:
find ~/.vim -type f -exec dos2unix \"{}\" \;这会将~/.vim目录下的所有文件转换为unix文件格式。它应该会删除您看到的^M错误。
发布于 2012-12-20 04:44:52
在你的.vimrc文件中我注意到
set ff=unix但是在vim中,下面的命令解释了一些事情。
:help dos-file-formats
If the 'fileformat' option is set to "dos" (which is the default), Vim accepts
a single <NL> or a <CR><NL> pair for end-of-line (<EOL>). When writing a
file, Vim uses <CR><NL>. Thus, if you edit a file and write it, Vim replaces
<NL> with <CR><NL>.
If the 'fileformat' option is set to "unix", Vim uses a single <NL> for <EOL>
and shows <CR> as ^M.
You can use Vim to replace <NL> with <CR><NL> by reading in any mode and
writing in Dos mode (":se ff=dos").
You can use Vim to replace <CR><NL> with <NL> by reading in Dos mode and
writing in Unix mode (":se ff=unix").
Vim sets 'fileformat' automatically when 'fileformats' is not empty (which is
the default), so you don't really have to worry about what you are doing.因此,您应该尝试删除
set ff=unix行,或者修复文件的行尾。
发布于 2013-01-23 08:04:10
我也有同样的问题。上面的解决方案(由calling提出),即在包文件上调用"dos2unix“,应该可以解决当前插件的问题。
将来,我发现我的问题是由于将git repos克隆到包目录并将git config core.autocrlf设置为true而导致的。在我将git config core.autocrlf设置回false之后,我再次对插件进行了git克隆,并返回到UNIX-y文件结尾。
https://stackoverflow.com/questions/13960696
复制相似问题