Home » Infrastructure » Unix » search and replace in vi editor
search and replace in vi editor [message #98335] Mon, 26 July 2004 04:36 Go to next message
BhavinShah
Messages: 105
Registered: February 2004
Senior Member
hi..
friends

is any search and replace facility in vi-editor like in windows system.
Re: search and replace in vi editor [message #98337 is a reply to message #98335] Tue, 27 July 2004 06:36 Go to previous messageGo to next message
Jai Vrat Singh
Messages: 205
Registered: September 2002
Location: Singapore
Senior Member
Yes .

e.g.

$ cat your_file
This is a nice dog. I like dogs coz' cats can betray.

if you open your_file,

1. ESC (press)

2. : (press)

3. %s/cat/girl/g (type and press enter)

You can do much much more that what you can do in a textpad etc in windows.
Re: search and replace in vi editor [message #98338 is a reply to message #98337] Tue, 27 July 2004 09:25 Go to previous messageGo to next message
andrew again
Messages: 2577
Registered: March 2000
Senior Member
Another variation is to use .../gc

The c means confirm which causes vi to prompt you for each replacement.
Re: search and replace in vi editor [message #98339 is a reply to message #98337] Tue, 27 July 2004 21:00 Go to previous messageGo to next message
BhavinShah
Messages: 105
Registered: February 2004
Senior Member
Thax,

By your help i have saved plenty of time ..

bye...
Re: search and replace in vi editor [message #98392 is a reply to message #98338] Wed, 08 September 2004 03:08 Go to previous message
Andy Black
Messages: 6
Registered: August 2004
Junior Member
Hiya,

You're actually using sed (stream editor) commands here.

Check out sed (there's plenty of good articles on the web) and you'll be flying. :)

Regards, Andy
Previous Topic: how can i know my default shell
Next Topic: oracle error with date and timestamp
Goto Forum:
  


Current Time: Mon Nov 25 21:40:50 CST 2024