LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   How to copy and paste things between vim and system clipboard (https://www.linuxquestions.org/questions/slackware-14/how-to-copy-and-paste-things-between-vim-and-system-clipboard-669721/)

Bruce Hill 09-14-2008 05:16 AM

Quote:

Originally Posted by grissiom (Post 3279871)
I forgot to mention that I'm using KDE4.1 testing package from slackware.com. But I think it maybe does not metter. On my box, middle click does not paste the words selected outside but same other words which I don't know where they come from. But Shift+middle click dose the work.

Besides, it's also unconvenience if I can only paste things in but cannot get things out.

In /usr/share/vim/vimrc have you commented set mouse=a ?

grissiom 09-14-2008 05:16 AM

Oh, IMHO, when set mouse=a, drag with left button could trigger visual mode, in which the selected content is handdled by vim internally but not X. So we cannot copy things out when mouse=a. But when set mouse=r, dragging mouse will not trigger visual mode so the selected content is passed to X. So we can copy things out.

Hmm,it's a pity that we cannot copy things out while in visual mode...

Bruce Hill 09-14-2008 05:29 AM

I think you have some conflict, perhaps in a vimrc you added
or something. Not only on 6 boxen on this LAN, but all other
computers where I've installed Slackware (I build and repair
them), commenting set mouse=a in /usr/share/vim/vimrc enables
highlighting with the left button and pasting with the middle
button -- everywhere.

grissiom 09-14-2008 05:44 AM

Quote:

Originally Posted by Bruce Hill (Post 3279901)
I think you have some conflict, perhaps in a vimrc you added
or something. Not only on 6 boxen on this LAN, but all other
computers where I've installed Slackware (I build and repair
them), commenting set mouse=a in /usr/share/vim/vimrc enables
highlighting with the left button and pasting with the middle
button -- everywhere.

Oh, yes. I'm sorry... I set mouse=a in ~/.vimrc ... ;(

mohtasham1983 09-25-2008 05:31 PM

Basically, set mouse=r, will let you copy from vim to X.

However, I rather have set mouse=a, where I can point to anywhere in the file using mouse. I don't copy things from vim to X very often. But if I want to do it, I write :set mouse=r real quick and copy it to the X.

Bruce Hill 09-25-2008 07:26 PM

Somehow my instructions are too complicated, or your
~/.vimrc files are overruling the system wide one, or
I am not understanding your problems or posts ...
Quote:

Why do they have these problems with ViM?

And why don't they comment out set mouse=a in /usr/share/vim/vimrc
and see how well it works?
I wrote that in GViM, and saved it. Then reopened it
and dragged the text with the left mouse button. Then
I copied it into here with the middle mouse button.

That is copying from ViM to X. As stated before, I can
copy and paste to and from ViM and every app in this way,
no matter where I start ViM from, too.

Also, it works for me with USB mouse, USB wireless mouse,
USB wireless mouse/kbd combo, PS/2 mouse, touchpad and
synaptic mouse. Only one I haven't tried it with is the
bluetooth mouse which default Slack kernel doesn't even
detect. When I have time for a custom kernel to get that
rodent working, I'll try it.

Maybe I'm missing something here and you can help me.

duryodhan 09-26-2008 12:48 AM

Ok ... lets get a few things cleared up ...

we are all talking about Slackware 12.1 stock install - no changes to the vim package ...

from inside xterm (while X is running i.e ) , open vim (thus the question of GPM doesn't arise)
I couldn't copy to-from vim ,

:set mouse=a allowed copy to vim
:set mouse=r allowed copy from vim


This is a pain in ass .. in earlier slackware versions I am pretty sure I could copy in either direction.

I tried recompiling with the --with-x option (by editing Pat's slackbuild .. but there was no difference)

Now ... how did anyone else solve this ?


I don't have a personal .vimrc nor have I touched the main vimrc.

Bruce Hill 09-26-2008 03:40 AM

Quote:

Originally Posted by duryodhan (Post 3292127)
Now ... how did anyone else solve this ?


I don't have a personal .vimrc nor have I touched the main vimrc.

Once again, might I suggest you "touch" the main vimrc?

Code:

mingdao@silas:~$ cat /etc/slackware-version
Slackware 12.1.0

mingdao@silas:~$ ls /var/log/packages/vim-
vim-7.1.330-i486-1_slack12.1      vim-gvim-7.1.330-i486-1_slack12.1

mingdao@silas:~$ less /usr/share/vim/vimrc | grep mouse
" In many terminal emulators the mouse works just fine, thus enable it.
" set mouse=a

mingdao@silas:~$ ls -l .vimrc
/bin/ls: cannot access .vimrc: No such file or directory

I can't remember if this bad behavior first started in vim
with Slack-12.0, or 12.1 -- however, doing just what you see
above allows me to copy into and out of vim into and out of
any app on my box.

I have installed the new version of these apps from Slack-12.1
patches, but vim-7.1.285-i486-1 worked the same. And it is now
working the same on many other boxen.

duryodhan 09-26-2008 04:18 AM

Quote:

Once again, might I suggest you "touch" the main vimrc?
doesn't really matter .. if you read the rest of the post .. I have manually done 'set mouse=a' and 'set mouse=r' and shared the results.

grissiom 09-26-2008 04:55 AM

OK, I'm using VIM7.2 from current but I think it shouldn't be a problem since there is no changes in copying part as far as I can see.

In my condition:

:set mouse=a allowed copy to vim (via middle-click)
:set mouse=r allowed copy from vim (via drag selection and middle-click in other space) and copy to vim (via middle-click)

I don't think touch /usr/share/vim/vimrc is a good idea because all the work can be done via edit ~/.vimrc. This doesn't hurt the root system.

Bruce Hill 09-26-2008 09:44 AM

Whatever ... my vim works. :D

sswam 02-19-2010 01:30 AM

for gvim, how to always use the system clipboard
 
how to fix gvim to use the clipboard directly: read the online help!

according to
:help clipboard

When the "unnamed" string is included in the 'clipboard' option, the unnamed register is the same as the "* register. Thus you can yank to and paste the selection without prepending "* to commands.

So check the output of
:set clipboard?

and add in ,unnamed,

for example, in my .vimrc,

set clipboard=autoselect,unnamed,exclude:cons\|linux

You still need to press yy to yank and p to paste, but it's easier than "*yy and "*p

mRgOBLIN 02-19-2010 04:34 AM

set mouse-=a

Another handy thing to add to vimrc is
Code:

set pastetoggle=<F11>
great for pasting if you have autoindent on

Rupa 02-19-2010 09:22 AM

Code:

set mouse=
does work for me on all computers and all vim versions. Either "set mouse=" in ~/.vimrc or type ":set mouse=" while working in vim.

dugan 02-19-2010 11:53 AM

I use the Slackbuild in /source to rebuild vim with the --with-x flag.


All times are GMT -5. The time now is 06:09 AM.