2012-12-19 39 views
4

我最近安裝了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://stackoverflow.com/questions/1110678/m-at-the-end-of-every-line-in-vim)。 – romainl

+0

我該如何解決這個問題?原諒我的無知 – Liam

+0

我看到你提供的鏈接,但我很困惑:%s/^ M $ //命令的應用。我已經嘗試在vim中打開pathogen.vim,它說沒有找到序列。 – Liam

回答

0

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

3

起殼,請嘗試執行以下命令:

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

這將所有文件轉換您~/.vim目錄到UNIX文件格式下。它應該刪除您看到的^M錯誤。

+3

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

0

我剛剛有同樣的問題。上述解決方案(由nullrevolution提出)在你的bundle文件中調用「dos2unix」應該可以解決你當前插件的問題。

未來,我發現我的問題是由於將git配置core.autocrlf設置爲true,將git repos複製到bundles目錄中導致的。在將git config core.autocrlf設置爲false後,我再次克隆了插件,並返回到UNIX-y文件結尾。