> Hello,
> I would like to know if it is possible to copy and paste in the vi
> editor. I am learning C++ programming (an absolute beginner), but the R
> 4.1 on my iMac does not have the backslash character. So, until my R5
> CD-ROM arrives, maybe I could use this hack someone suggested to me.
> Could someone tell me how to use the copy-paste?
> Thanks in advance.
> Jean-Michel
If you're running vi in an Xwindow, you can also do Xcopy and paste.
Select the text like on a Mac or PC, use vi commands to move to where
you want to paste, make sure you are in insert mode and use the middle
mouse button paste. Be careful if a section of text your copying is more
than one line long, you may not get the effect you desire, especially
wrt to the CR/LF at the end of lines. It's far safer to use vi yank and
paste, but takes some getting used to. I would stronly recommend the
Nutshell book on vi, or at least one of the many quick reference cheat
sheets available (there are several out on the net, I printed one and
laminated it to have it handy). Vi is a strange beast. At first glance
it seems like it doesn't do much and is counter intuitive, but the more
you use it the more powerful it becomes!
Also remember that most vi commands can be modified to alter their
scope. Thus d (delete, like cut) or y (yank, like copy) will cut/copy
the character the cursor is on 2d 2y will take the next character as
well. 2dw will yank 2 words and so on.
Re your missing backslash, vi also has the ability to map special
functions and create small macros. You could for example look up the
ascii character number for \ and create a map in vi so that you could
generate it quickly from the keyboard. Hope this helps.
-Rich