[ale] Carriage returns and line feeds

DJ-Pfulio djpfulio at jdpfu.com
Mon Mar 2 06:17:54 EST 2015


Figured this had to be a joke - actually had a tear from the laughter.

If this is serious, David's answer works for vim ... but it is typed as
"cntl-v{enter}" to get "^V^M" into the substitute command.  That's a
lowercase-"v".  Probably helpful to force vim in binary mode too .... vim -b
filename.

Or there is a utility - dos2unix ... if you want the opposite, there is a
unix2dos util too. These are probably easier for most people. They are filters,
so redirect the output to a new file, if you want to save it.


On 03/02/2015 12:06 AM, David Ritchie wrote:
> Well, LF "\n" always means end of line in a linux text file. vi/vim simply
> ignores CRs...
> 
> Perhaps this will work for you in vim:
> 
> :%s/.$//  (delete the CR at the end of each line)
> 
>    or :%s/^V^M//g
> 
> which says find all cntl-M (CR's) in a line and replace with a null strings
> 
> Note the the ^V is a control-V that will tell the command to except a
> control character as part of a pattern.
> 
> -- David
> 
> 
> 
> On Sun, Mar 1, 2015 at 11:37 PM, Alex Carver <agcarver+ale at acarver.net>
> wrote:
> 
>> How do you propose to mark the end of a line when \r\n is the end of the
>> line?
>>
>> On 2015-03-01 20:26, Terry wrote:
>>> Is there a way to remove all the \r\n embedded in a txt file except the
>> ones at the end of each line?
>>>
>>> Thanks,
>>>


More information about the Ale mailing list