简体   繁体   中英

Syntax issues with vim when open a file from another editor

I used to edit all my files with Vim and i never got problems with it. But, yesterday i take back some work from a developper and open the files he gaves me.

I don't really know why but Vim reads it as one line only :

<?php ^M $lesdatas=file_get_contents('datas.dat'); ^M $datas=explode('=>',$lesdatas);
foreach ($datas as $data) { ^M // comment ^M $vals=explode('==',$data);

Etc etc...

Looks like vim can't interpret ^ M as a 'Enter'.

How can i convert the file to read it normally ?

Thx for your help guys

Looks like the file is encoded in (traditional) Apple Mac format, using Carriage Return (CR, ^M ) as the end-of-line delimiter (Windows uses CR-LF ^M^J , Unix LF ^J ). Try opening the file with

:edit ++ff=mac filename

If you need to open such files often, adapt your 'fileformats' setting, as described under :help fileformats .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM