^M displayed in vi but not in vim

2007-05-09 Thread Dan Fabrizio
Hi all,

Does anyone know why vim don't show the ^M characters in a file but vi does?

:set list  

in vim shows $ at the end of the lines but no ^M characters?  

:set ff=unix
:w

This removed the ^M characters but I had to use vi to verify.

Is there some setting I'm missing that needed to show the ^M characters in
vim?

Thanks in advance,
Dan




Re: ^M displayed in vi but not in vim

2007-05-09 Thread A.J.Mechelynck

Dan Fabrizio wrote:

Hi all,

Does anyone know why vim don't show the ^M characters in a file but vi does?

:set list  

in vim shows $ at the end of the lines but no ^M characters?  


:set ff=unix
:w

This removed the ^M characters but I had to use vi to verify.

Is there some setting I'm missing that needed to show the ^M characters in
vim?

Thanks in advance,
Dan




:verbose set ff? ffs?

If 'fileformats' (plural) includes dos, the fact that you don't see a ^M 
when lines end in CR+LF is not a bug, it's a feature (which is not present in 
Vi, and I mean the original Vi, not Vim running in 'compatible' mode).


If 'fileformats' includes dos, the 'fileformat' (singular) will be set to 
dos for files with CR+LF ends-of-lines, and all lines will be written with 
CR+LF unless you tell Vim not to, by using e.g. setlocal ff=unix.


See for details:
:help 'fileformat'
:help 'fileformats'
:help file-format
:help file-read
:help DOS-format-write
:help Unix-format-write
:help Mac-format-write

To check the ends-of-lines for a file loaded in a window:

:setlocal fileformat?

The answer can take three possible values:

  fileformat=dos

The file contained CR+LF endings, and it will be written back using CR+LF 
endings. If 'fileformats' (plural) does not include unix, it is possible 
that the file included one or more lines with LF-only endings; they will be 
repaired to CR+LF when you save the file.


  fileformat=unix

The file contains LF endings; any spurious CR's are shown as ^M

  fileformat=mac

The file contains CR-only endings.


Best regards,
Tony.
--
It would be nice if the Food and Drug Administration stopped issuing
warnings about toxic substances and just gave me the names of one or
two things still safe to eat.
-- Robert Fuoss


Re: ^M displayed in vi but not in vim

2007-05-09 Thread Yeti
On Wed, May 09, 2007 at 12:39:45PM -0400, Dan Fabrizio wrote:
 Does anyone know why vim don't show the ^M characters in a file but vi does?

Vim understands all EOL types.  All types included in
'fileformats' are equal, whatever characters they are
physically represented with.

 :set list  
 
 in vim shows $ at the end of the lines but no ^M characters?  

$ marks ends of lines, it does not stand for any particular
character.  If lines are ended with CRLF, CR (^M) is simply
a part of end of line, it is not included in the text.

 :set ff=unix
 :w
 
 This removed the ^M characters but I had to use vi to verify.

You can display the current EOL style ('fileformat') any
time:

  :set ff

 Is there some setting I'm missing that needed to show the ^M characters in
 vim?

If you do not want to accept CRLF as end of line, do not
include `dos' in 'fileformats'.  Then only the LF part
becomes end of line, CR will be included in the text.  You
will see ^M displayed as you wish, however, semantically it
is not the same.

Yeti

--
http://gwyddion.net/