Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!pilchuck!ssc!fyl From: fyl@ssc.UUCP (Phil Hughes) Newsgroups: comp.editors Subject: Re: A vi question Summary: it works with ed, why not vi Keywords: vi, substitute Message-ID: <149@ssc.UUCP> Date: 20 Aug 90 19:09:26 GMT References: <1990Aug12.194738.7902@ecn.purdue.edu> <14420003@hp-lsd.COS.HP.COM> <1990Aug16.130232@ecn.purdue.edu> Distribution: na Organization: SSC, Inc., Seattle, WA Lines: 26 In article <1990Aug16.130232@ecn.purdue.edu>, patkar@ecn.purdue.edu (Anant Y Patkar) writes: > Just to clear the confusion. What I needed was to change > quadruple occurances of any letter to a single occurance. > That means if I use individual substitute commands for each > letter, I am stuck with 52 commands (some files I have need > more commands to take care of some other characters). > The solutions I > received my mail indicate that (possibly) there is no way to > do this using the "ex" commands. You have to invoke some UNIX > commands like 'sed' from inside vi to do this. Here is my solution which worked fine in ed but does not work in vi (which I don't understand). I expect that ex would be happy with it as well but didn't try it. Anyway, the idea is to just look for any character followed by 3 more of the same character and replace it by one of the character. %s/\(.\)\1\1\1/\1/g (And to think I avoided the "remember this" constructs for years. :-) -- Phil Hughes, SSC, Inc. P.O. Box 55549, Seattle, WA 98155 (206)FOR-UNIX uunet!pilchuck!ssc!fyl or attmail!ssc!fyl (206)527-3385