[comp.unix.questions] @ macros in vi

gregg@ihlpb.ATT.COM (Wonderly) (03/10/89)

From article <1742@ssc.UUCP>, by bel@ssc.UUCP (BF):
> Does anyone know how to properly use the macros to 
> put macro body in buffers using yank or delete operators in vi?
> 
> The information I have is:
> 
> @x invokes macros
> @@ repeats last macro
> 
> I have been told these may not work.
> Are these buggy on some systems?

The usage is

	"[a-z]y<some-movement>

or

	"[a-z]d<some-movement>


"				means you type a "
[a-z]			means one of the 26 letters (named buffers)
y or d			means you are either yanking or deleting into the
				named buffer
<some-movement> means move the cursor to the end of the region that
				you wish to put into the buffer.

typical usage would be that you have the command sequence on a line

yWi^I^Icase ^[A:^M^I^I^Idebug ("case ^[pa\n");^M^I^I^Ibreak;^M^[^M

which convienently changes

FOO
BAR
FOOBAR

to

		case FOO:
			debug ("case FOO\n");
			break;

		case BAR:
			debug ("case BAR\n");
			break;

		case FOOBAR:
			debug ("case FOOBAR\n");
			break;

Do this by typing '"ayy' to yank it into the 'a' buffer followed by
placing the cursor on the line reading FOO and typing '@a' three times.

If you have the string

w !spell | more

on a line and type '"byy' on that line followed by typing
`:@b', then you will write the buffer to the spell command which will
route its output to the more command via the pipe (this is all taken care
of by the shell, not vi).

There are lots of variations on this theme...

-- 
Gregg Wonderly                             DOMAIN: gregg@ihlpb.att.com
AT&T Bell Laboratories                     UUCP:   att!ihlpb!gregg

jpr@dasys1.UUCP (Jean-Pierre Radley) (03/17/89)

From article <1742@ssc.UUCP>, by bel@ssc.UUCP (BF):
> Does anyone know how to properly use the macros to 
> put macro body in buffers using yank or delete operators in vi?

I can commend and recommend a dissertation on this very subject written by
Fred Buck, and available in one of the Libraries of the TANGENT Forum on
Compuserve.

It is a thorough and clear exposition of mapping and macro assignment in
vi.
-- 
Jean-Pierre Radley		Honi soit		jpr@dasys1.UUCP
New York, New York		qui mal			...!hombre!jpradley!jpr
CIS: 76120,1341			y pense			...!hombre!trigere!jpr