Edit file on Windows, shows ^M on each line on Linux
tensai at zmonkey.org
Fri Apr 13 10:31:19 MDT 2007
On Fri, 2007-04-13 at 09:42 -0600, Joseph Hall wrote:
> Window and DOS use <CR><LF> as its end of line marker, whereas Unix
> and Linux only use <LF>. When you open a Windows file in something
> such as vi in Linux, you get ^M at the end, which represents the <CR>.
Depending on your vi, you may not even see the ^M. VIM for example is
smart enough to detect DOS file endings and will use the alternate form.
When you open such a file you'll see "[DOS]" down in the status line,
indicating that's what happened. You can force one or the other with
":set ff=dos" or ":set ff=unix" before you ":w".
There is the problem of what to do if half the line endings are <CR><LF>
and half are <LF>. In that case I think VIM assumes Unix mode and will
show ^M on any line that has it. Use ":s/^V^M//" to fix it, as mentioned
elsewhere in this thread.
More information about the PLUG