@ macros in vi

Wonderly gregg at ihlpb.ATT.COM
Fri Mar 10 08:29:50 AEST 1989


>From article <1742 at ssc.UUCP>, by bel at 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 at ihlpb.att.com
AT&T Bell Laboratories                     UUCP:   att!ihlpb!gregg



More information about the Comp.unix.questions mailing list