Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!pur-ee!pc.ecn.purdue.edu!cb.ecn.purdue.edu!patkar From: patkar@cb.ecn.purdue.edu (The Silent Killer) Newsgroups: comp.editors Subject: Re: question about "vi" Message-ID: <692@cb.ecn.purdue.edu> Date: 11 Feb 89 16:07:15 GMT References: <740@bnlux0.bnl.gov> Reply-To: patkar@cb.ecn.purdue.edu.UUCP (The Silent Killer) Organization: Purdue University Engineering Computer Network Lines: 27 In article <740@bnlux0.bnl.gov> como@bnl-max (Andrew T. Como) writes: > >I have a question about vi. > >Here are five lines: > The cow jumped over the moon > The cow jumped over the moon > The cow jumped over the moon > The cow jumped over the moon > The cow jumped over the moon > > How can I substitute /cow/dog only on lines 1 and 5 > Try /cow, then :/s/cow/dog followed by nnnn& '&' repeats the previous substitution. Actually in this case, you can also try /cow [return] cwdog[escape]nnnn. The first version has the advantage that it remembers only the exact latest substitution done through 'ex' (i.e. in the command mode), whereas the '.' command remembers any non-ex change like deleting a line, etc. I am sure somebody will correct me if I am wrong. Anant Patkar (patkar@neon.ecn.purdue.edu)