Path: utzoo!mnetor!tmsoft!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!uunet!pcserver2!ddsw1!dattier From: dattier@ddsw1.MCS.COM (David W. Tamkin) Newsgroups: comp.editors Subject: Re: Global Empty Line Removal in vi? Message-ID: <1991Jan26.233521.17721@ddsw1.MCS.COM> Date: 26 Jan 91 23:35:21 GMT References: <1991Jan24.163844.7521@unmvax.cs.unm.edu> Organization: Contributor Account at ddsw1, Wheeling, Illinois Lines: 30 crowley@unmvax.cs.unm.edu (Charlie Crowley) wrote in <1991Jan24.163844.7521@unmvax.cs.unm.edu>: | In <1991Jan24.064310.8077@midway.uchicago.edu> | zi0h@quads.uchicago.edu (W. Ishii) writes: | > | >Hello there! As a vi novice (maybe a stronger term is called for--vi idiot, | >probably), I've been stuck for about a week now trying to figure out how to | >globally remove multiple blank lines from text. | | Another solution is to use the regular expression capabilities of the ex/ed | editor underlying vi. To wit: | | :g/^$/d Er, uh, not quite. :g/^$/d (or more simply, :v/./d, delete all lines on which a search for . [wildcard for any character except newline] fails) will remove ALL blank lines. The original question was to reduce every series of consecutive blank lines to one blank line. Now, several people have posted that cat -s will do that. *That works only on Berkeley UNIX systems.* The version of cat in System V-land doesn't support that option: it uses -s for "silent" [i.e., don't say anything if a requested input file doesn't exist]. Running something with multiple blank lines through System V's cat -s doesn't strip the extra blank lines. One can always toss together a sed script. If I can get one to work (I've been trying, but hey, I'm an amateur and a novice at this), I'll post it. David Tamkin Box 7002 Des Plaines IL 60018-7002 708 518 6769 312 693 0591 MCI Mail: 426-1818 GEnie: D.W.TAMKIN CIS: 73720,1570 dattier@ddsw1.mcs.com