Loading ...
Sorry, an error occurred while loading the content.

Re: Trailing ^M ...

Expand Messages
  • Tony Mechelynck
    ... The above will remove any carriage-returns anywhere. My previous proposal will suppress at most one carriage-return per line, and only at the end. Here s
    Message 1 of 8 , Apr 30, 2009
    • 0 Attachment
      On 30/04/09 08:45, Matt Wozniski wrote:
      >
      > On Thu, Apr 30, 2009 at 2:30 AM, pansz wrote:
      >>
      >> Tony Mechelynck 写道:
      >>>
      >>> IMHO, in Vim 7.2.040 and later, by opening it with
      >>>
      >>> :e ++ff=dos somestuff.txt
      >>
      >> Things can be worse than that: I've seen files mixed with \r\r\n and
      >> \r\n and \n at the end of line. in which case ++ff=dos does not solve
      >> the problem. since there's extra ^M there.
      >>
      >> so I'd always recommend a single command :%s/^M//g
      >
      > But that would ruin a file that intentionally had ^M in it - like some
      > ex scripts, for instance.
      >
      > ~Matt

      The above will remove any carriage-returns anywhere. My previous
      proposal will suppress at most one carriage-return per line, and only at
      the end. Here's an additional variant, to suppress any number of
      carriage-returns but only at the end of a line:

      :%s/\r*$//

      Vim regexps are pretty powerful, but of course you've got to know what
      you want to do with them.

      Best regards,
      Tony.
      --
      People who develop the habit of thinking of themselves as world
      citizens are fulfilling the first requirement of sanity in our time.
      -- Norman Cousins

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    Your message has been successfully submitted and would be delivered to recipients shortly.