Copy and paste from one vi session to another session?

Copy and paste from one vi session to another session?

Post by keith f » Fri, 10 Jan 2003 22:24:17



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!
 
 
 

Copy and paste from one vi session to another session?

Post by Barry Kimelma » Fri, 10 Jan 2003 23:10:18


[This followup was posted to comp.unix.questions and a copy was sent to
the cited author.]



Quote:> 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!

Like most (if not all windows programs) I believe Reflection has a "Copy"
command (under the Edit menu ??). Highlight the desired code and copy the
code to the clipboard. Start the new VI session and use the "Paste"
command to insert the old code.

Or :  write the old code out to a temporary file, start a new VI session,
read in the old code, delete the temp file.

--
---------

Barry Kimelman
Winnipeg, Manitoba, Canada


 
 
 

Copy and paste from one vi session to another session?

Post by Chuck Dillo » Fri, 10 Jan 2003 23:24:52



> 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!

Vi doesn't do copy and paste since it's a tty based program.  Copy and
paste functionality has to be provided by a GUI based application.  For
example, if you run vi in an xterm the xterm provides text selection,
copy and paste functionality in the X world.  If the emacs you refer to
is an X based emacs, as opposed to straight tty, it provides the
selection+copy+paste functionality.  On the other hand if you run vi in
a terminal emulator on a MS-Windows box (e.g. telnet session) the
MS-Windows appliction has to provide the select+copy+paste features in
the context of the MS-Windows world.  If you are running X on
MS-Windows the Xserver (e.g. ReflectionX) has to bridge between the
copy/paste buffers in the X and MS-Windows worlds if you want to be
able to copy and paste between those worlds.

I can't be more specific without more specific information.

-- ced

--
Chuck Dillon
Senior Software Engineer
NimbleGen Systems Inc.

 
 
 

Copy and paste from one vi session to another session?

Post by Sven Maschec » Sat, 11 Jan 2003 00:47:28




>> How do you copy some code from one vi seesion to another vi session.
> Vi doesn't do copy and paste since it's a tty based program.  Copy and
> paste functionality has to be provided by a GUI based application.  For
> example, if you run vi in an xterm the xterm provides text selection,
> copy and paste functionality in the X world.

There's also screen(1) (switching between multiple sessions on one TTY)
which allows entering a copy&paste mode and navigating the cursor with
the keyboard.  (Apart from all the other great stuff in screen.)

Sven

 
 
 

Copy and paste from one vi session to another session?

Post by John Gordo » Sat, 11 Jan 2003 01:57:16



> Hi,
> How do you copy some code from one vi seesion to another vi session.

write the text out to a temporary file, and then import that file
into the other session.

to write some text out to a file, the command is:

  :position1,position2w filename

where "position" can be an an absolute line number, $ for end of file,
. for current line, .+X for current line +X, or even a search command.

for example, to write lines 5 through 20 to a file called /tmp/xyz:

  :5,20w /tmp/xyz

to read the contents of a file into the current text, the command is:

  :r filename

the text will be inserted below the current line.

Quote:> 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.

  :n               begin editing the next file (if you invoked vi on
                   several files)

  :e filename      begin editing filename

  :e #             begin editing the previous file

(you must save any changes to the current file before switching files, or
else the changes will be lost.)

to copy and paste text between files in a single vi session, you can
used named buffers:

"ayy      yank the current line of text into named buffer a

"g23yy    yank the current line of text plus the following 22 lines
          into named buffer g

"dp       insert the contents of named buffer d

there are 26 named buffers, a-z.

---
John Gordon                  "No Silicon Heaven?  Preposterous!  Where would

 
 
 

Copy and paste from one vi session to another session?

Post by co » Sat, 11 Jan 2003 06:50:42



Quote:>How do you copy some code from one vi seesion to another vi session.

When you delete or yank into a buffer ( a through z), f.i.
"xdd , leave vi, start vi again, the deleted line still is
in buffer x. (yank is copy, about).
Marking can easily be done in visual mode. In command mode
press v,V,^v to mark char,line,column. Next "xd or "xy to
delete or yank into buffer x. To paste in command mode
use p or P (after,before cursor or line, depending on visual
mode). When you don't specify a buffer , the default buffer
is used. To view buffers use :reg .
www.vim.org is the site, the manuals are,well you will see.
Like :help. See visual.txt for marking.
www.grafnetix.com/~laurent/vim/faq.html

cor

 
 
 

1. copy+paste during vi session in an xterm

I recently moved to XFree86 3.1.2 (slackware 3.0), and found that
if I run vi (elvis) in an xterm I cannot copy and paste using mouse. But
copy and paste in shell is fine; copy and paste in vi and a normal
Linux console also works fine.

My last version of XFree86 was pretty old and did not have the problem.
I vaguely remember hearing this problem from others; a suggested solution
is to use vim. vim indeed works fine; but I just wonder why vi won't
work ...

Please advice. Thanks!


2. Setting a ROOT server - HELP

3. how can I copy&paste between 2 open vi sessions

4. Desktop size?

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

6. perl: warning: Setting locale failed

7. Linux reads only first session from a multi session CD

8. Compare 2 files question

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

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

11. Only first session available on multi session CD

12. xcdroast: multi session - sessions do not match

13. writing cdrtools session over an existing session