Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
irritating ^M at the end of ach line
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  1 message - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Tony Mechelynck  
View profile  
 More options Sep 19 2012, 10:52 am
From: Tony Mechelynck <antoine.mechely...@gmail.com>
Date: Wed, 19 Sep 2012 16:52:33 +0200
Local: Wed, Sep 19 2012 10:52 am
Subject: Re: irritating ^M at the end of ach line
On 19/09/12 16:24, rudra wrote:

An annoying ^M at the end of each line, or at the end of each line
except the last one?

It is a common defect of many ill-conceived Windows editors, that they
fail to put a proper end-of-line at the end of the last line. In that
case, Vim doesn't see the file as being in "dos" fileformat, because one
of the lines (the last one) lacks a DOS/Windows-like end-of-line. It
opens the file as "unix" fileformat then, with a visible ^M at the end
of every line except the last. This ensures that any line which ended in
CR+LF will keep it, and that any line which ended in LF only won't get
an added CR before it.

To "repair" the file and make sure that every line, including the last
one, ends in CR+LF, open it with ++ff=dos (see :help ++opt)
either (if the file was already open in Vim)
        :e ++ff=dos
or (if it wasn't)
        :e ++ff=dos filename.ext

++ff=dos will regard either CR+LF or LF-alone as an end-of-line, and
regard the file as being in "dos" fileformat. (This requires Vim 7.2.040
or later; if you still have an earlier version, I recommend that you
upgrade ASAP the latest published version of the sources is 7.3.666.)

This won't help if one or more lines end in CR+CR+LF (i.e. with two or
more carriage-returns before the linefeed). In that case, write the file
as unix and reopen it as dos to eliminate one level of spurious carriage
returns. Or else, if you have lines with many carriage-returns at the end,

        :%s/\r\+$//
        :setlocal ff=dos
        :w     " optional - you may do it later on

will eliminate any number of carriage-returns except one (and add one if
there were none) immediately before the linefeed at the end of a line.

Best regards,
Tony.
--
ARTHUR:        I command you as King of the Britons to stand aside!
BLACK KNIGHT:  I move for no man.
                                   The Quest for the Holy Grail (Monty
Python)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »