vi - macros using @ symbol

Hellmuth Broda whbr at cgch.UUCP
Fri Mar 10 21:17:17 AEST 1989


In article <1742 at ssc.UUCP> Belinda Frazier writes:
>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
>
Belinda

Try the following approach:

At some conspicious place in your file (I usually use the first line in
the file so that I won't forget about it) type the commands in input
mode which you would normally type in command mode.  Then yank that
text into a named buffer (e.g. "xY) and issue that macro from command
mode (@x).

Here is an Example that might get you started:

Let's assume that you want to put some key words from some (LaTeX)-
Document into the index.

Write the following line of text somewhere in your file:

yWEa\index{^[pi}^[
yWEa\index{pi}

(that line spells:
yank Word goto-End-of-Word add `\index{' ESC put Word add `}' ESC 
Note: you have to enter an ESC as ctrl-V ESC).

Then put the cursor at the beginning of that line and type
"xy$
(yank into named buffer `x' until end-of-line)

Now put the cursor at the word you want to index and press
@x

Here is how it works:  
...an example of getting some key words into the index of your document...
                                                 ^put cursor here, type @x
and your line will change to:
...an example of getting some key words into the index\index{index}  of your document...
---voila'

>[...]
>
>Thanks for any help.
>Belinda Frazier

You are welcome!
Hellmuth Broda
 ___________________________________________________________________________
| Dr.rer.nat. Hellmuth W. Broda |  c/o CIBA-GEIGY Scientific Computing Ctr. |
| Biologist and Systems Analyst |  R-1045.3.16, P.O.Box, Tel:+4161 697-7109 |
| UUCP:...!uunet!mcvax!cernvax!cgch!whbr         CH-4002 Basel, Switzerland |
| Internet:whbr%cgch.uucp at uunet.uu.net; BITNET:whbr%cgch.uucp at cernvax.bitnet|
 ---------------------------------------------------------------------------
                ``Chemists do it periodically on the table.''



More information about the Comp.unix.questions mailing list