views:

755

answers:

2

I'm using Vim 7.2 , compiled with +xterm_clipboard , in a xterm through putty . I've put set clipboard=unnamed in .vimrc , and from what i've read in other threads , this should put all yanks/deletes to the system clipboard. However , when I'm trying to paste whatever i've yanked to a MS app like notepad, its not working.

When I select text in vim using mouse , it automatically gets copied to the system(MS clipboard). I'd like to have the same functionality while using keyboard commands like 3yy .

Can anyone tell me what I'm doing wrong ?

+2  A: 

Try

"+3yy
"*3yy

"+p
"*p
Michael Krelin - hacker
Can you tell me how to do a `"+p` in notepad ? :)What you told me would work if I open another vim session and paste it there - I know that . What I wanted was a way to copy it into the Windows clipboard , which I can then paste it into notepad !If you think I was a bit unclear, I'm being even more explicit : I'm running Win XP on my PC , and using putty to get an xterm on the remote machine , where the file is opened in vim !
shan23
In the notepad you do paste. I'm not sure exactly how it works on windows, but on unices it yanks stuff into "system" selection. I'd guess that one of those will do that on windows as well. It also depends on the Xserver implementation on the windows and how it handles selection. I can only give you a vim-related part of the answer.
Michael Krelin - hacker
Thats what I wanted to convey : yanking text to system buffer does not put it in the windows clipboard , and hence I can't paste it anywhere. I guess the answer , if it exists , would involve setting some putty/X configurations to ensure vim has a way of putting text in the windows clipboard.
shan23
I'm not quite sure I understand what your setup it. You mention both putty and xterm. Does it mean that you run local X-server, connect to the machine using putty and then using putty's tunnel open xterm on your local X-server? If so, then you should look into your X-server settings. I haven't seen windows X-server for about 10 years now... ;-)
Michael Krelin - hacker
OK - so here's my setup :1) Native OS is win XP2) I have a account in a linux box which I connect to using Putty3) The value of the $TERM env variable is TERM=xterm4) The shell I primarily use in my linux accout is tcsh 5) I use vim 7.2I appreciate your efforts to answer my question - and thats why I'm trying to be as precise as possible in my description !!
shan23
Ah, so you *don't* use xterm, you use putty and hope it will behave like xterm. Which may be possible, but it's beyond my expertise. I'd look for putty options. Not sure if there are any of interest...
Michael Krelin - hacker
A: 

If you were running vim locally, then either

"+p
"*p

would work, as mentioned by hacker. Since you're sshed into another box, these will just copy text to the clipboard of the box you're sshed into.

What you need is the putty method of copying text, which is just highlighting the text you want to copy with the mouse.

While sshed into vim though, I usually use ALT + highlight with the mouse (for block selection), as I usually have line numbers on.

Hope this helps!

Nick Knowlson
Yes , I know using mouse works - thats mentioned in the question. But the point of using vim is that you don't have to depend on the mouse - there's always an alternative (usually). However, in this case , I think I'm asking a bit too much of vim , so I guess i'll have to look for ways of sharing clipboards across ssh !!
shan23
Oh right, I missed that bit, sorry! If your vim is compiled with the X11 and xterm_clipboard features enabled, and you turn on X11 forwarding in PuTTY, then this might work.
Nick Knowlson
Where 'this' is "+p etc.
Nick Knowlson
As far as I remember , I had enabled X11 forwarding in putty ... but it was still not working - I'll check and verify
shan23
X11 forwarding means you can run a graphical application on the Linux box and have the GUI appear on the windows box you're connecting from. You might want to try running xvim/gvim.
Adam Luchjenbroers