[comp.editors] vi yank to buffer

Dan_Bloch@TRANSARC.COM (03/24/91)

elliott@quando.quantum.de (C. David Elliott) writes:

> Is there a way to yank a specified set of lines into a cut-buffer?  Like:
>
> :120,145 "aY
> or
> :.,/}/ "aY

Sort of.  The good news is yes, you can say

    :120,145y a
    or
    :.,/}/y a

The bad news is that in all the versions of vi I know, it only works once
per vi session.

By the way, the most interesting use of this is to do something like

    :g/foo/y A

which puts all lines containing "foo" into buffer a.

Dan Bloch
dan@transarc.com

carl@mugwump.UK.Sun.COM (Carl Johnson - Sun EHQ - MIS) (03/25/91)

In article <Mbux9mj0BwwZ5CIowW@transarc.com>, Dan_Bloch@TRANSARC.COM writes:
> 
>     :120,145y a
>     or
>     :.,/}/y a
> 
> The bad news is that in all the versions of vi I know, it only works once
> per vi session.

Que?  What did you mean by this last bit, as everything I have tried works more
	than once.

Cheers,
Carl.

Dan_Bloch@TRANSARC.COM (03/28/91)

carl@mugwump.UK.Sun.COM (Carl Johnson - Sun EHQ - MIS) writes:

> In article <Mbux9mj0BwwZ5CIowW@transarc.com>, Dan_Bloch@TRANSARC.COM writes:
>
>>     :120,145y a
>>     or
>>     :.,/}/y a
>>
>> The bad news is that in all the versions of vi I know, it only works once
>> per vi session.
>
> Que?  What did you mean by this last bit, as everything I have tried
> works more than once.

My apologies.  This does reveal a bug in vi, but it's not the one I thought
it was, nor is it nearly as serious.  If you do some of the more complicated
forms of the y command (e.g. :g/foo/y A) once or twice, vi gets into a state
where it can't remember the contents of any of its buffers.  Once you edit
your file in any way (e.g. deleting a character and undoing the change), vi
remembers the buffers again.

So, use the commands in good health.  If vi beeps when you try to paste
the buffer, make any change and it should work.

> Cheers,

Cheers-
Dan