vi

I have a file that at some point I removed all ^Ms and now I'm trying to put a newline return where the ^Ms used to be.

I probably removed the ^Ms a few years ago in Linux or SCO Xenix and now I'm using a MAC.

With the file opened with vi I have tried the following:

:%s/\.[A-Z]/\.^N[A-Z]/g

I'm entering the ^N as ctrl-V ctrl-N and the /g is because as the file stands now I have 2 really long lines.

The results I'm getting are just the literal ^N[A-Z].

I could be wrong, but on unix machines (like the Mac :stuck_out_tongue_winking_eye: ) the line endings (newline character) are generally referenced in regular expressions as "\n".

yes?

Not being a vi guy, I do not know if regular expressions are handled the same way there...

without having to go to vi editor, you cud just use use

sed 's/.*$/&\^N/g' filename > outfile

or inside vi, u cud do

:1,$s/.*$/&\^N/g

cheers,
Devaraj Takhellambam

the up carrot M is the Microsoft equiv to carriage return.
if they are appearing in the document or file its because they were either created or modified in MS Notepad or WordPad

I haven't seen them actually impacting or impair the operation, so I ignore them.

In Linux, the simplest way to get rid of those funnies is using dos2unix command. No idea if something similar exists in OS X

I've been using this to remove the annoying ^M from dos files:

col -bx <dosfile> newfile

and I'm pretty sure it works under OS X.

al
....

A dos2unix-like tool for the Mac may be found here:

OS X Apps > search: "newline"

Cheers,
verno