[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: vi

> What I missed most, and missed on years of word processors, is the
> trivially easy manner of making compound, repeated, commands. 

yes, this is especially important when you consider that editing config
files often requires making substantially the same change to many lines.

the generic example:

:map , n.

a more concrete example.  your network has been renumber and you need to
change all occurences of 192.168.1 with 192.168.200 in the following text.

IPADDR=""	# REPLACE with YOUR IP address!
NETMASK=""	# REPLACE with YOUR netmask!
NETWORK=""	# REPLACE with YOUR network address!
BROADCAST=""	# REPLACE with YOUR broadcast address, if you
GATEWAY=""	# REPLACE with YOUR gateway address!

1G                  # move to start of file
/192.168.1          # search for 192.168.1
5cw192.168.200<ESC> # change 5 'words' to 192.168.2
n                   # find next
.                   # repeat change
n                   # find next
.                   # repeat change
n                   # find next
.                   # repeat change
:x                  # save and exit

takes probably all of 5 seconds. to do the same in a modeless editor
like pico or joe would involved dozens of extra cursor movement, insert,
and delete commands (you can't just do a simple overstrike because
'.200' is longer than the '.1')

you could also do the same with search and replace (but there are many
similar types of edit jobs where S&R is not appropriate because it may
have unintended consequences...e.g. you want to change some but not all
occurences of a string).  

Even where S&R is appropriate, it is much simpler to type:


than it is to type or mouse-click your way through one or two or more
dialog boxes (i.e. mode changes).


Reply to: