Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!hplabs!hpda!hpcupt1!hprnd!egt From: egt@hprnd.HP.COM (Eric Tausheck) Newsgroups: comp.editors Subject: Re: Re: A vi question Message-ID: <3440004@hprnd.HP.COM> Date: 23 Aug 90 21:06:06 GMT References: <14420003@hp-lsd.COS.HP.COM> Organization: HP Roseville Networks Division Lines: 40 > > I had the need to do this kind of editing too until I learned about > col -b. > > If what you started with had a bunch of back-spaces between the > letters too (as in an nroff or man output), the filter "col -b" does a > nice job of getting rid of all this junk for you. I should have added that before I discovered the "col -b" filter, I used to execute the following vi command to nroff output: :%s/.^H//g (where the "^H" is entered with VH) On a more interesting note... > > :s/\(.\)\1\1\1/\1/g > >which works in "ed", but for some reason it didn't work in "vi". So the >next best thing (if you really must do it from within vi) is to use '!' to >filter the relevant text through "sed". E.g. for the whole file: > > 1G!Gsed 's/\(.\)\1\1\1/\1/g' This is very powerful (of ed and sed). Thanks for sharing this gem regarding sed/ed. A shame vi/ex doesn't implement it because it would (almost?) give vi/ex true complete regular expression matching capabilities. I'm very rusty on my formal language theory so for all I know this (ability to self reference to patterns during regular expression matching) may have given vi/ex full regular expression matching capabilities - anyone out there care to speculate? Eric Tausheck email: egt@hprnd.hp.com Hewlett Packard Co.