From: Massimo Pilolli (maxpilolli@user.ats.it)
Date: Wed Feb 10 1999 - 23:30:53 CET
Michele Andreoli wrote:
>
> On Wed, Feb 10, 1999 at 10:22:25AM -0800, Andrea Manzini wrote:
> > Hi everyone,
> >
> > does 'elvis' in mulinux support macros ?
>
> No. This is a "tiny" elvis, without macro (i think ...)
....what a pity!
> > How do I write one ? How to recall it ?
> > Can you make an example of a macro ?
> > Many thanks :)
> >
> >
>
> Max Pilolli can answer you: tell Max for vi-muman contribute.
> Ciao.
>
Well, the basic idea is: write a command (or a SET of commands)
in a named buffer (macro) and recall it.
For example, if you wish to remove the last character of each row
in your 4000 rows file (perhaps the hateful ^M) you should:
1- go to the last line of your file and create a new line
(empty or not: it will be destroyed in the end of this process)
2- create a new line and insert $x (you want to go at the end of
each line - command $ - and delete the last character - command x)
Probably (sorry, I don't remember and I can't test it) you should
NOT add the j command to make vi act in the next line: I think
vi will do this by itself.
3- Now, you are in insert mode (you are writing $x in a new line).
Well: go in command mode. Write the $x set of commands in a macro:
3.1- press " (= write...)
3.2- T (for example: anyway an UPPERCASE letter.
It means: ...in the macro named 'T')
3.3- dd (you're canceling the new line containing $x, and thus
the $x will be put in the macro called 'T'. OK?)
4- Now, insert a new line containing @T (= recall T macro, so it will
produce a little loop: the T macro will call itself). So:
4.0- create a new line and insert @T
4.1- press " (= write...)
4.2- T (...in the SAME macro named 'T')
4.3- dd (you're canceling the new line containing @T, and thus
the @T will be put in a new line of the macro called 'T')
5- Go to the first line of your file. Recall T macro with @T
It should work, if I've remembered each detail. You know:
vi is not exactly an user-friendly text editor.
Comments: the name of the macro MUST be an UPPERCASE letter:
a lowercase one can be only the name of a macro that contains no
further macro.
Anyway, I don't know if all this is the standard way to build macros:
I used such a similar macro some years ago in a RISC 6000 workstation
(AIX o.s.) just to clean a 4000 lines FORTRAN program (you guessed:
there were the bloody ^M in it!).
Ciao.
Max
This archive was generated by hypermail 2.1.6 : Sat Feb 08 2003 - 15:27:11 CET