Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!lll-lcc!unisoft!peritek!dig From: dig@peritek.UUCP (David Gotwisner) Newsgroups: comp.editors Subject: Re: question about "vi" Message-ID: <397@peritek.UUCP> Date: 11 Feb 89 11:45:19 GMT References: <740@bnlux0.bnl.gov> Organization: Peritek Corp., Oakland, CA Lines: 39 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 # # I guess what I'm asking is if I # search for cow - /cow/ # now substitute - s/cow/dog/ # skip the next 3 lines n n n # ...how can I re-issue the same substitution when I come to line 5 # If you use :s/cow/dog in the first place, go to the next line wanting changing and type :~ If you change the first one using cwdog or cedog, go to the next line wanting changing and type . (that's right, just a period). A third way is to type :g/cow/s//dog/c (c for confirm). Vi will type the line, with ^^^^ under it. Type a y to change it, type or n to not change it. Similarly, you could have typed :1,5s/cow/dog/c, or some other flavor of the same. There are probably at least 100 other ways of doing it. :-) -- ------------------------------------------------------------------------------ Dave Gotwisner UUCP: ...!unisoft!peritek!dig Peritek Corporation ...!vsi1!peritek!dig 5550 Redwood Road Oakland, CA 94619 Phone: 1-415-531-6500