does vi have a search/deletion macro???

David I. Berg dberg at cod.NOSC.MIL
Sun Sep 10 07:17:21 AEST 1989


In article <4237 at ncar.ucar.edu>, morreale at 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 <string> <filename> )
>       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/<string>/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/<string>/d      (That says global search for string and delete.)

-- 
David I. Berg (dberg at nosc.mil)
GENISYS Information Systems, Inc., 4250 Pacific Hwy #118, San Diego, CA 92110
MILNET: dberg at nosc.mil
UUCP:   {akgua decvax dcdwest ucbvax}!sdcsvax!noscvax!dberg



More information about the Comp.unix.questions mailing list