VectorLinux

Please login or register.

Login with username, password and session length
Advanced search  

News:

Visit our home page for VL info. For support and documentation, visit the Vector Linux Knowledge Center or search the Knowledge Center and this Forum using the search box above.

Author Topic: Vim: problems copying text from vi to another application  (Read 1937 times)

ted1959

  • Member
  • *
  • Posts: 9
Vim: problems copying text from vi to another application
« on: December 25, 2007, 10:20:46 am »

I have just installed VL 5.9 Gold. So far it's looking pretty good. But I have found a problem when I'm editing a text file in a terminal with vi. When I select some text the text doesn't get copied to the clipboard - after selecting the text if I then click on the edit menu the "Paste" option is greyed out. If I open another application where I can paste in some text there's nothing in the clipboard to paste in.

Any idea why this is happening?
Logged

kidd

  • Packager
  • Vectorian
  • ****
  • Posts: 682
Re: Vim: problems copying text from vi to another application
« Reply #1 on: December 25, 2007, 11:19:44 am »

Vim's clipboard system behaves in a weird way if you don't fully understand it.

I'll try to write a small introduction to it:

1.) Clipboards in X windows:

X running in linux environments has 2 registers where you can copy/paste text.
   - ctrl-c/ctrl-v
   - Mouse selection / middle-click (or shift-insert)

2) Vim and registers:
   You can refer to a given register prepending a double quote (") and the register ID to the yank command
   Vim has lots of registers where you can leave and retrieve text.  Most common ones are the numbered registers, ", +, * and '/'.
   When you copy anything with 'y', this text gets pushed into '"' register, and the "0. "0 goes to "1, "1 goes to "2.....
   If you specify a register, the text will be placed in the specifyed reg, and the "0 reg. "0 goes to "1, "1 goes to "2.....
   
   "+ refers to the ctr-c/ctrl-v clipboard, and "* refers to the mouse selection/shift-ins one.

   copying a line to the "+ register is done with "+yy
   pasting a the "+ register is done with "+p

   If you don't wanna mess with all that (It's powerful, but a bit complicated), you can set an option to your ~/.vimrc

   :set clipboard=unnamed

   This way, "* register will be used when you don't specify any register.  This way, vim shares the clipboard with other applications and other vim instances (without special tricks).


aditional help in :h clipboard, and :h 'clipboard'     inside vim.

HTH

ted1959

  • Member
  • *
  • Posts: 9
Re: Vim: problems copying text from vi to another application
« Reply #2 on: December 25, 2007, 09:09:56 pm »

Thanks for the info on pasting in vim.

I am trying to do all my copy/pasting using mouse selections and middle mouse button clicks for pasting the text into other applications.
I also have an installation of Ubuntu in which I can do this. I have been studying the various vim setup files but still haven't figured out how to configure it.
Logged