[Dclug] annoying Ctrl-M characters

Ed T. Toton III bones at necrobones.net
Mon Jul 2 17:01:37 EDT 2007


Thus spake James Ewing Cottrell 3rd:

> Ed T. Toton III wrote:
>> Within vi, I've often used a regex to remove the carriage returns when the 
>> file originated from a windows/DOS environment. ^M is just a carriage 
>> return character (since DOS/Win uses a CR/LF combo to terminate lines 
>> instead of just the linefeed).
>> 
>>         :1,$s/\r$//
> 99% credit. :%s/\r$//
>
> Now are you tying a backslash followed by an r? I didn't know that 
> worked. Fair Trade.

Heh, well since I stay in the habit of specifying ranges so as not to 
accidentally alter more than intended. It's not always about minimalistic 
typing. :)

But yeah, vi seems happy with \r for carriage returns, \n for newlines, \t 
for tabs, etc, as one might expect, despite the otherwise lack of 
robustness in its regex support.


------------------------------------------------------------------
- Ed T. Toton III, RHCE --|-- www.necrobones.com -- ed.toton.org -
------------------------------------------------------------------
"His mind is like a steel trap -- full of mice" -- Foghorn Leghorn




More information about the Dclug mailing list