how can I copy&paste between 2 open vi sessions

how can I copy&paste between 2 open vi sessions

Post by terry433.. » Wed, 08 Dec 2004 18:41:00



say I have 2 files opened in vi :-
$ vi file1 file2

and while editing file1 I use vi copy feature (yank)
20yy

and then I switch to file2 using vi ':n'

I am unable to paste previous copy using vi 'p' command

what am I doing wrong here, why is the info in the buffer from file1
unavailable to file2????

also  - what is opposite of vi ':n' command i.e. how do I go back to
file1 from file2 ?

 
 
 

how can I copy&paste between 2 open vi sessions

Post by Thomas Maier-Komo » Wed, 08 Dec 2004 19:03:29



> say I have 2 files opened in vi :-
> $ vi file1 file2

> and while editing file1 I use vi copy feature (yank)
> 20yy

> and then I switch to file2 using vi ':n'

> I am unable to paste previous copy using vi 'p' command

> what am I doing wrong here, why is the info in the buffer from file1
> unavailable to file2????

seems like solaris' vi cannot do this. use vim instead (delivered with
the companion cd) under /opt/sfw/bin/vim.

Quote:

> also  - what is opposite of vi ':n' command i.e. how do I go back to
> file1 from file2 ?

try :b

 
 
 

how can I copy&paste between 2 open vi sessions

Post by Stephane CHAZELA » Wed, 08 Dec 2004 19:23:57



Quote:> say I have 2 files opened in vi :-
> $ vi file1 file2

> and while editing file1 I use vi copy feature (yank)
> 20yy

> and then I switch to file2 using vi ':n'

> I am unable to paste previous copy using vi 'p' command

> what am I doing wrong here, why is the info in the buffer from file1
> unavailable to file2????

[...]

Because the default register is local to the buffer. IIRC, the
captital letter registers such as "A are global on those ancient
vi's.

Try

"A20yy
:n
"Ap

--
Stephane

 
 
 

how can I copy&paste between 2 open vi sessions

Post by Martin Pau » Wed, 08 Dec 2004 20:37:21



> say I have 2 files opened in vi :-
> $ vi file1 file2

> and while editing file1 I use vi copy feature (yank)
> 20yy

> and then I switch to file2 using vi ':n'

> I am unable to paste previous copy using vi 'p' command

Try "a20yy in the first file, and "ap in the second one.

Quote:> also  - what is opposite of vi ':n' command i.e. how do I go back to
> file1 from file2 ?

:rew will go to the first file. AFAIK there is no command to go back
to the previous file in stock Solaris vi (like :prev in vim).

mp.
--
Systems Administrator | Institute for Software Science | Univ. of Vienna

 
 
 

how can I copy&paste between 2 open vi sessions

Post by Jeffery Sma » Thu, 09 Dec 2004 03:28:35




>> say I have 2 files opened in vi:      $ vi file1 file2

>> and while editing file1 I use vi copy feature (yank):     20yy

>> and then I switch to file2 using vi:  ':n'

>> I am unable to paste previous copy using vi 'p' command
>seems like solaris' vi cannot do this. use vim instead (delivered with
>the companion cd) under /opt/sfw/bin/vim.

On Solaris 9 my copy of /bin/vi (Version SVR4.0, Solaris 2.5.0) will paste
between two files using any named buffer.  However, I agree that using vim(1)
is a good idea.

Quote:>> also  - what is opposite of vi ':n' command i.e. how do I go back to
>> file1 from file2 ?
>try :b

You can toggle back and forth between the last two active files with Control-^
(e.g. Control and the '6' key) assuming you do not have unsaved changes in the
current file.

If you use vim(1) take a look at the :buffers command.  It is very flexible in
allowing you to move between any number of active files.

Regards,
--
Jeff

C. Jeffery Small           CJSA LLC                     (206) 232-3338

 
 
 

how can I copy&paste between 2 open vi sessions

Post by Rich Tee » Thu, 09 Dec 2004 04:25:51



> seems like solaris' vi cannot do this. use vim instead (delivered with

It can.  You have to use named buffers.

--
Rich Teer, SCNA, SCSA, author of "Solaris Systems Programming"

President,
Rite Online Inc.

Voice: +1 (250) 979-1638
URL: http://www.rite-group.com/rich

 
 
 

how can I copy&paste between 2 open vi sessions

Post by Rich Tee » Thu, 09 Dec 2004 04:25:27



> say I have 2 files opened in vi :-
> $ vi file1 file2

> and while editing file1 I use vi copy feature (yank)
> 20yy

> and then I switch to file2 using vi ':n'

> I am unable to paste previous copy using vi 'p' command

> what am I doing wrong here, why is the info in the buffer from file1
> unavailable to file2????

You have to yank the stuff you want to copy into a named buffer.
So, to yank the first ten lines of your file into buffer a, you say:

:1,10y"a

Back in the first file you just say "ap

Quote:> also  - what is opposite of vi ':n' command i.e. how do I go back to
> file1 from file2 ?

:rewind

--
Rich Teer, SCNA, SCSA, author of "Solaris Systems Programming"

President,
Rite Online Inc.

Voice: +1 (250) 979-1638
URL: http://www.rite-group.com/rich

 
 
 

1. Copy and paste from one vi session to another session?

Hi,
How do you copy some code from one vi seesion to another vi session. I
guess if I knew how to operate multiple vi sessions with in one
reflection window, I could do this, but I am unsure of how to do that,
too.
I can do it using emacs, but would like to learn how to do it with vi.
Any vi web sites would be helpful, too.
Thanks!

2. in Khtml - <caption>

3. copy+paste during vi session in an xterm

4. i740 chipset

5. why does open vi session tab data that is pasted into it

6. Slapper

7. Block Copy & Paste in VI?

8. PC-COM 4 port

9. vi with copy & paste ?

10. COPY&PASTE does not work with vi editor

11. elvis (vi) in an xterm session: cut and paste problems

12. In 'vi' I can't copy and paste!!