[comp.editors] vi @-macros

keck@shiva.trl.oz (Brian Keck) (10/09/89)

I have a question about vi @-macros

I know that if I insert a line 
  oabcESC
in the main buffer and move it to the buffer called "a" by saying
  "add
then I can insert "abc" by saying
  @a

But can I define @-macros in my .exrc file ?
If my .exrc file is
  a
  oabcESC
  .
then vi dumps core.

Thanks

Brian Keck                                ACSnet[Internet]: keck@trlsasb.oz[.au]
Telecom Australia Research                               Phone: +1 61 3 541 6407
P.O. Box 249 Clayton, Victoria 3168, Australia                        
Brian Keck                                ACSnet[Internet]: keck@trlsasb.oz[.au]
Telecom Australia Research                               Phone: +1 61 3 541 6407
P.O. Box 249 Clayton, Victoria 3168, Australia                        

maart@cs.vu.nl (Maarten Litmaath) (10/10/89)

keck@shiva.trl.oz (Brian Keck) writes:
\... But can I define @-macros in my .exrc file ?

map @a ...
-- 
The UNIX Way of doing something [...] is to make it look as much like a filter
as possible.  (Richard O'Keefe)        | Maarten Litmaath (mcsun!botter!maart)

keck@shiva.trl.oz (Brian Keck) (10/10/89)

In article <3623@ski.cs.vu.nl> maart@cs.vu.nl (Maarten Litmaath) writes:
>keck@shiva.trl.oz (Brian Keck) writes:
>\But can I define @-macros in my .exrc file ?
>
>map @a ...
>

Well yes ...
The reason I asked was that I've had startup messages from vi like 
  "too much macro text", and thought that this was because I had
  too many maps in my .exrc.  It was always cured by deleting some.
Now I find I can have lots more maps (total 66 at least) without getting
  complaints.  What might have been worrying vi ?


Brian Keck                                ACSnet[Internet]: keck@trlsasb.oz[.au]
Telecom Australia Research                               Phone: +1 61 3 541 6407
P.O. Box 249 Clayton, Victoria 3168, Australia                        

bengsig@oracle.nl (Bjorn Engsig) (10/11/89)

Article <758@trlluna.trl.oz> by keck@shiva.trl.oz (Brian Keck) says:
|The reason I asked was that I've had startup messages from vi like 
|  "too much macro text", and thought that this was because I had
|  too many maps in my .exrc.
This is normal if you have your cd in your HOME.  Then vi will read .exrc
twice, and if you have more than half the macro space used, you will get the
message during the second read.
-- 
Bjorn Engsig, bengsig@oracle.nl, bengsig@oracle.com, mcvax!orcenl!bengsig

mercer@ncrcce.StPaul.NCR.COM (Dan Mercer) (10/12/89)

In article <754@trlluna.trl.oz> keck@shiva.trl.oz (Brian Keck) writes:
:I have a question about vi @-macros
:
:I know that if I insert a line 
:  oabcESC
:in the main buffer and move it to the buffer called "a" by saying
:  "add
:then I can insert "abc" by saying
:  @a
:
:But can I define @-macros in my .exrc file ?
:If my .exrc file is
:  a
:  oabcESC
:  .
:then vi dumps core.
:
:Thanks
:
:Brian Keck                 ACSnet[Internet]: keck@trlsasb.oz[.au]
:Telecom Australia Research                Phone: +1 61 3 541 6407
:P.O. Box 249 Clayton, Victoria 3168, Australia                        
:Brian Keck                 ACSnet[Internet]: keck@trlsasb.oz[.au]
:Telecom Australia Research                Phone: +1 61 3 541 6407
:P.O. Box 249 Clayton, Victoria 3168, Australia                        

Oddly enough,  I've had need to do this very thing.  Believe me,  it
tore me up in knots before I stumbled on the answers.  We needed to preload
a bunch of macros tied to our pfkeys because we perceived a storage
problem with macro space.  Turned out,  we only had the problem when
editing in our HOME directories.  our HOME/.exrc was being entered
twice - once as the HOME/.exrc and the second time as ./.exrc.  We
finally solved that problem by moving almost all editable files out
of HOME and into more appropriate subdirectories.

Meanwhile,  we stumbled onto the answer to the above puzzle.  Below
is a sample .exrc file:


e tmpBuf                # open a temporary file - this prevents core
0a                      # append after zero
:!echo it worked        # load command to temp file
.                       # EOF
1d a                    # delete line 1 into buffer a
w! /dev/null            # save file to /dev/null: this unblocks exrc processing

The file you are editing is only opened after exrc processing.

I hope this helps.  I tried it out and it seems to work on my system. 
I can't access the system the actual code was written for (they're
having modem problems).  When I can,  I'll go look over my old
files and make sure there aren't any sneaky refinements I overlooked.


-- 

Dan Mercer
Reply-To: mercer@ncrcce.StPaul.NCR.COM (Dan Mercer)