vi search & replace functions

I'm trying to do a global search and replace in vi. I am trying to replace a string, call it "BOB" with a carriage return and can't seem to find a reference to it.

Command syntax s%/BOB/???/g

What would I substitute the "???" with?

I guess you can try the following

:%s/BOB/^V<Carriage Return>/

here carriage return is the carriage return key

I tried this and it worked for me. hope it does for u too

Thanks, the carriage return key didn't work, but using the ^V followed by ^M worked fine. Thanks....db

hit the ctrl key + v then hit the carriage return.

Probably worth noting that <control>-v is used to escape and specify literal characters.

O'Reilly is giving away (for free), pdf copies of "Unix Text Processing" by Dale Dougherty and Tim O'Reilly. It was good when published in 1987 and is still worth looking at today. Hayden, the original publisher, took the book out of print, but Dale and Tim retained the copyright and have decided to make it available.

http://www.oreilly.com/openbook/utp/

Cheers,

Keith

Very helpful, thanks....db

Thanks keith, I got one for myself :slight_smile:

Also, in vi you can do this:

:g /dsk/s//rdsk/g

This will also replace global values as well...