Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!microsoft!steveha From: steveha@microsoft.UUCP (Steve HASTINGS) Newsgroups: comp.editors Subject: Re: Global Empty Line Removal in vi? Message-ID: <70525@microsoft.UUCP> Date: 7 Feb 91 05:01:24 GMT References: <1991Jan24.163844.7521@unmvax.cs.unm.edu> <1991Jan26.233521.17721@ddsw1.MCS.COM> <1991Jan27.073848.27626@ddsw1.MCS.COM> <1991Jan30.001551.7538@unmvax.cs.unm.edu> <2704@wn1.sci.kun.nl> Reply-To: steveha@microsoft.UUCP (Steve Hastings) Organization: Microsoft International Products Group Lines: 24 In article <2704@wn1.sci.kun.nl> hansm@cs.kun.nl (Hans Mulder) writes: > :g/^$/+s//qqq/ This changes the next line, but only if > ^^^^ it, too, matches the pattern. This inspired me to come up with the following. Note that it is only possible to use this in ex mode; you have to use Q to exit vi to ex mode, and you can use the ex "vi" command to switch back. -- cut here -- cut here -- cut here -- cut here -- cut here -- cut here -- g/^[ ]*$/.,/[^ ]/-1c\ \ . -- cut here -- cut here -- cut here -- cut here -- cut here -- cut here -- This finds all runs of lines containing only whitespace, and changes them to a single line with no characters on it. I was trying to put this in a file and execute it from vi with a :source command, but I couldn't make it work. Can anyone tell me why it shouldn't work that way? -- Steve "I don't speak for Microsoft" Hastings ===^=== ::::: uunet!microsoft!steveha steveha@microsoft.uucp ` \\==|