Newsgroups: comp.editors
Path: utzoo!sq!lee
From: lee@sq.sq.com (Liam R. E. Quin)
Subject: Re: Typing long commands in vi
Message-ID: <1990Aug12.203740.10166@sq.sq.com>
Organization: SoftQuad Inc.
References: <56433@microsoft.UUCP>
Date: Sun, 12 Aug 90 20:37:40 GMT
Lines: 45

steveha@microsoft.UUCP (Steve Hastings) writes:
>Some long, powerful vi commands can be hard to get right in one try.
and suggests two ways to make it easier.

I think it worth clarifying this a little.

One way is to type
:.,$s/hello/goodbye
or whatever, *into the text*, move onto the line if necessary, and say
	"ayy
to put a copy of the line into register a, or
	"add
to delete the line altogether, and then
	@a
to execute the contents of register a -- i.e., to do the substitution.

You could put
map g "add@a
into your .exrc, and then you simply type a g on the command.

If you have deleted the command into the register, and then you found you
got it wrong, you can bring it back again with
	"ap
or
	"aP
if you want.  Of course, you can undo the delete as well.

If instead of doing "add you move to the start of the line and do "ad$
there will be no newline at the end of the register, of course, so you
will be left (when you do @a) on the bottom line with
the cursor here ---+
:.,$s/hello/goodbyeX
so you can backspace over the command or add to it.  I sometimes use this
with
:!ls file | awk '{something ghastly here}' | sed .....
so I can build the command up easily.

This technique was used in the word-completion macros posted here recently.

Lee
-- 
Liam R. E. Quin,  lee@sq.com, {utai,utzoo}!sq!lee,  SoftQuad Inc., Toronto
``He left her a copy of his calculations [...]  Since she was a cystologist,
  she might have analysed the equations, but at the moment she was occupied
  with knitting a bootee.''  [John Boyd, Pollinators of Eden, 217]
