Subject: Re: Can't stand vi
To: The Great Mr. Kurtz [David A. Gatwood] <davagatw@Mars.utm.edU>
From: Uncle John <happy@dircon.co.uk>
List: port-mac68k
Date: 12/10/1996 23:01:32
At 11:27 10/12/96, "The Great Mr. Kurtz [David A. Gatwood]"
>I haven't figured out a simple way to do that in vi, either, but then I've
>never really tried that hard.

Well, basically you type:

:%s/theword/thereplacement/g

: puts vi in 'ex' command mode
%s is 'substitute', theword is what, thereplacement is what with, 'g' being
globally.

Basically, it's regex for 'theword'. It's incredibly powerful.

I have some data files like this:

user1:prefe1:mango:banana
user2:admin:wibble:heck

If I just want user names (quickly) in vi, you can do: ":%s/:.*//g", and it
deletes everything from the 1st colon onwards (or rather, substitutes it
with a null string).

Kinda fun :)

John.

                     "It's not a Bug(TM) it's a Feature"

 ["Bug" is a registered trademark of Microsloth Corp. All wrongs reserved]

    +-+-+ Admin on Monochrome (telnet 138.40.17.10 for more details) +-+-+
                  Email tugs@mono.org || happy@dircon.co.uk