Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!ukc!pyrltd!root44!gwc From: gwc@root.co.uk (Geoff Clare) Newsgroups: comp.editors Subject: Re: A vi question Message-ID: <2394@root44.co.uk> Date: 22 Aug 90 12:47:21 GMT References: <14420003@hp-lsd.COS.HP.COM> <3440002@hprnd.HP.COM> <1990Aug19.174035.3946@cid.aes.doe.CA> Organization: UniSoft Ltd., London, England Lines: 32 Somebody asked: >>> > I need to do the following in vi. >>> > ccccoooossss -> cos afsipmh@cid.aes.doe.CA (Patrick Hertel) wrote: > I have seen a lot of answres of this type in the last fwe days but it >seems obvious, to me at any rate , that the question reffered to a more >general solution. ie he wants to know how to edit out the quadrupling >of letters not just the specific case of ccccoooossss. I am not >experienced enough with vi to supply an answer but so far I haven't seen it. That's also how I read the original question. My first attempt was to try this: :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' or, if the backspaces from nroff emboldening are still there: 1G!Gsed 's/\(.\)^H\1^H\1^H\1/\1/g' (where ^H is entered using CTRL-V CTRL-H). -- Geoff Clare (Dumb American mailers: ...!uunet!root.co.uk!gwc) UniSoft Limited, Hayne Street, London EC1A 9HH, England. Tel: +44-71-315-6600