Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.csd.uwm.edu!cs.utexas.edu!swrinde!ucsd!nosc!cod!dberg From: dberg@cod.NOSC.MIL (David I. Berg) Newsgroups: comp.unix.questions Subject: Re: does vi have a search/deletion macro??? Summary: global search and delete Keywords: vi, macros, TFM?, glasses Message-ID: <1633@cod.NOSC.MIL> Date: 9 Sep 89 21:17:21 GMT References: <4237@ncar.ucar.edu> Distribution: usa Organization: Naval Ocean Systems Center, San Diego Lines: 19 In article <4237@ncar.ucar.edu>, morreale@bierstadt.ucar.edu (Peter Morreale) writes: > 1) How can I search for a string and have all occurrences show > on my screen (aside from doing a :!grep -i ) > because then I want to.... > > 2) delete all lines which match the above mentioned search. To display all lines with a character string satisfying a search criterion, use :g//p (That says global search for string and print.) If you want to list the lines with line numbers, use "nu" in place of "p". To delete all lines with a character string satisfying a search criterion, use :g//d (That says global search for string and delete.) -- David I. Berg (dberg@nosc.mil) GENISYS Information Systems, Inc., 4250 Pacific Hwy #118, San Diego, CA 92110 MILNET: dberg@nosc.mil UUCP: {akgua decvax dcdwest ucbvax}!sdcsvax!noscvax!dberg