vi and sed questions

Fred Rowland rowland at hpavla.HP.COM
Fri Sep 8 22:09:27 AEST 1989


Two questions about editing; one about vi and one about sed!

I've been using these programs for several years and have never
been able to find answers.  I'd appreciate help.

vi question

	There are lots of neat things you can do by mapping a
series of commands to a key (` is my favorite).  If the
command string ends with (Ctrl-V)(Return), you can hold the
key down and load up some command buffer with multiple copies
of the command string.  The effect is that the command marches
down through the file as you watch the action.  But it's slow;
far slower than an addressed or global action.  But it's also
versatile--you can accomplish things that can't be done using
addressed or global stuff.  Is there any way to "load up" a
key with the command string and then execute it via an
addressed or global command?

	Example:

	lastname firstname middlename @address@ ...

	can be changed to

	firstname middlename lastname @address@ ...

	by this key mapping:

	:map ` 0dwf$P(CTRL-V)(Return)

	Just start at line 1, hold ` down, and watch the fun.
	But there ought to be a better way.


sed question

	The file used in the above example is a mail list which
has to be converted into labels.  I add three @ symbols to the end
of each line, then convert all of them to newlines.  I can do this
in vi but I get substitution overflows as the file grows considerably
in size.  I would prefer to use sed, but how do you tell sed to
split a line (generate a newline)?  I've tried various 
combinations of \(Return), \n, CTRL-V, and such but nothing
works.  I EVEN READ THE MANUAL!  It told me to use \n and
gave an example.  It didn't work.  This has to be possible, but
how?


Thanks,
Fred (perplexed) Rowland
Hewlett-Packard Avondale Division



More information about the Comp.unix.wizards mailing list