views:

549

answers:

7

in gvim on windows if I have text with CRLF eol then the text will display ^M at the end of each line.

How do I 'hide' that special char from display?

the :set nolist command """ does not dismiss it. I am stumped.

UPDATE

I did :set fileformats=unix,dos as a list but it didn't work at first. I closed the file and reopened it again and it worked. By default I had set fileformats to only unix value. Thanks for answers.

+1  A: 

You may want to set fileformat to dos.

:ed ++ff=dos %

Michael Krelin - hacker
This seems to "fix" the file adding dos linebreaks wherever they are missing, which may be what causes vim to display the ^M markers (was in my case).
numerodix
A: 
:0,$ s/<ctrl-v><ctrl-m>//g
:set ff=dos
John Millikin
A: 

use the command:

:1,$ s/^v^M/ /g

Lonzo
Hide, not remove.
Dave Jarvis
touche` -- I missed that finer point as well (though I *did* make a copy, rather than whack the original)
Roboprog
+1  A: 

The file format is usually automatically detected. You must have mixed Unix and DOS/Windows lines in your file.

try this to clean it up (where "clean" = unix format):

% tr -d '\015' < old.file > new.file
Roboprog
Er, you did say "on windows". Oops. Well, suffer, then? Everybody has cygwin, right? I suppose there's a lot more Windows programmers than *nix programmers, but I tend to forget this (despite starting on MS-DOS in the 80s). Can't stand the thing, myself...
Roboprog
+3  A: 

To hide them:

:set fileformats=dos

To remove them (so you can later save the file as a unix file):

:%s/\r//g
jqno
A: 

I'd like to point out that if you are using full blown VIM (at least on my ubuntu 9.10 box) it "does what you want" and auto-hides it, but the stock vi (and vim-tiny) do NOT auto-hide the ^M. If you do a minimal install (or server install) you get vi and vim-tiny only. The fix I found was to install proper vim (apt-get install vim) on my ubuntu box. Hope that helps someone that comes along this topic for the same reason I did :-D

Mark McCorkle
A: 

I do have the ^M characters only in the command box. (even when my files are dos).

Why this?

remio