cygwin内的vim病原体错误

问题描述:

我最近安装了cygwin(因为我限于Windows操作系统),并且想在其中使用Vim。一切都安装好了,我可以随时访问vim,并可以修改.vimrc之类的东西。从之前的文章中,我了解到我的插件必须在Windows操作系统的vimfiles中,并且已经这样做了。但是,现在当我尝试验证病原体我得到一个错误,指出:cygwin内的vim病原体错误

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 

问候,

+2

它看起来像你的一些文件,例如'autoload/pathogen.vim',有窗口行尾。 [修复](http://*.com/questions/1110678/m-at-the-end-of-every-line-in-vim)。 – romainl

+0

我该如何解决这个问题?原谅我的无知 – Liam

+0

我看到你提供的链接,但我很困惑:%s/^ M $ //命令的应用。我已经尝试在vim中打开pathogen.vim,它说没有找到序列。 – Liam

在.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 

线,或修复您的文件的行结束。

+0

谢谢,我在搜索其他相关帖子后添加了ff = unix,并在失败后忘记删除它。这似乎修复了它。 – Liam

+0

对不起,这实际上没有解决它。仍然得到^ M的错误。认为它是干净的,但在重新打开vim之后,它仍然不起作用。 – Liam

+0

要在插入模式下或在输入命令时插入^ M,必须先发出CTRL + V,后跟CTRL + M。这样你应该能够删除不需要的字符。 – Truc

起壳,请尝试执行以下命令:

find ~/.vim -type f -exec dos2unix \"{}\" \; 

这将所有文件转换您~/.vim目录到UNIX文件格式下。它应该删除您看到的^M错误。

+3

在我的环境中(Cygwin),这个'find〜/ .vim -type f -exec dos2unix'{}'\;'起作用,但你的不是。 – Hong

我刚刚有同样的问题。上述解决方案(由nullrevolution提出)在你的bundle文件中调用“dos2unix”应该可以解决你当前插件的问题。

未来,我发现我的问题是由于将git配置core.autocrlf设置为true,将git repos复制到bundles目录中导致的。在将git config core.autocrlf设置为false后,我再次克隆了插件,并返回到UNIX-y文件结尾。