On Fri, Feb 22, 2002 at 09:06:50AM +0200, Tzafrir Cohen wrote:
> On Fri, 22 Feb 2002, Shlomi Fish wrote:
> > map <F3> 5gg"ny$gg$a[<C-R>n]<ESC>5gg<C-X>
> Just in case vi doesn't have a viable solution for that (or just in case
> you want to further complecate Adi's life) recall that vim (not vi) also
> has functions.
My life is sufficiently complicated by the command itself :)
A few notes in case you want to make it intra-vi portable (using
the '^' notation for special characters):
5G is the traditional way to do exactly the same thing as 5gg .
Less characters to type, too. Likewise, 1G is gg .
Traditional vi doesn't have that many commands in insert mode,
so the portable way to do a[^Rn] is a[^["npa]^[ .
^X is a vim-only command -- both nvi and vim support #- which
does the same thing, and therefore is more portable (as well as
easier to remember IMHO). IRIX vi supports neither. If you want to
be /that/ portable, you may have to jump through the following
hoop: A-1^[!!bc^M . An incredibly useful command, this !.
Note that it only pipes complete lines, though, which is one of
the more annoying vi/ex limitations in my opinion, and the reason
why I wrote !! instead of !$ . There might be more elegant ways to
do the same thing using some ex abuse, but I can't think of any.
The last thing is that traditional vi macros (in IRIX, at least,
nvi is fine with that) can't do yank/paste operations on
incomplete lines, so you'd have to adjust the logic a bit. I
admit it sucks.
So far I have:
which works even on my IRIX. Yay. INTERCAL never had a chance.