Xavier
Xavier

Reputation: 4017

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

Upvotes: 0

Views: 49

Answers (1)

Ingo Karkat
Ingo Karkat

Reputation: 172778

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.

Upvotes: 1

Related Questions