Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vi question

Status
Not open for further replies.

rondebbs

MIS
Dec 28, 2005
109
0
0
US
Hello, I am editing a text file with vi. I am using 's' in command mode to substitute certain text string. For example I am using .,$s/dog/cat/g. This changes all the occurences of 'dog' to 'cat'.

Is there a way that I can recall this command in vi(similar to esc k)? Sometimes I want to make a slight modification and run the command again.

Also, is there a good document that covers vi in detail? I learned the substiute command above form a co-worker but I'm not really sure what all the characters (.,$s/dog/cat/g)mean.
 
Try the
As to the your substitution string of ".,$s/dog/cat/g", here's a brief explaination:

the ".,$" portion is the range of the search and replace. The character before the "," tells where to start the search and replace operation. The character after the "," tells where to end the operation. The "." in the range means the current line and the "$" means the last line in the file. So the range operation will go from the current line you are on to end of the file.

The "s" means to perform a substitution.

The string between the first and second "/" is the that will be replaced.

The string between the second and third is the replacement string.

The "g" at the end means to replace all occurances on the line. If you leave it off, only the first occurance will be replaced.

Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top