[ale] Copying from vi into another terminal

David S. Jackson deepbsd at earthlink.net
Mon Sep 29 11:51:46 EDT 2003


On Mon, Sep 29, 2003 at 07:51:53AM -0400 John Wells <jb at devsea.com> wrote:
> If you have a file open in vi, is there a way to highlight text and copy
> in to an X-win buffer so you can paste it in another terminal?  In other
> words, copy the text in vi, but paste to a non-vi destination.

Mostly the cut/paste in X works okay for me, but with heavily
indented texts, sometimes the wrapping and indenting gets messed up.
So I just do a 

:set nu
:20,50w newfilename

to create a block of text named "newfilename" from lines 20 to 50 in
the original text.  Then, in the target document, place your cursor
where you want to insert the text and type either :R newfilename or
:r newfilename, depending on where you want the new text relative to
the current cursor location.  (You could also do a :!rm newfilename
to remove the temporary file, once you've copied it.)

There are lots of other ways to do it, though.  You can use markers,
regular expressions, macros and cut buffers.  You could run all vi
sessions in a terminal multiplexer like (err, I forgot the name of
that really popular one...).  Or, you can, edit several documents in
several buffers from the same vi session (some modern vi's, such as
Vim, are quite good at using several buffers).  That would make the
job you describe very easy.


-- 
David S. Jackson                                dsj at dsj.net
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
"The Schizophrenic: An Unauthorized Autobiography"



More information about the Ale mailing list