开发者

Copy text from Vim 7.2 running in xterm to windows clipboard

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 开发者_如何学JAVAtext 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 ?


Try

"+3yy
"*3yy

"+p
"*p


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!


I'm trying to figure out how to get vim inside PuTTY (no xterm involved) to interact with the Windows clipboard.

My research so far indicates it's not possible. xterm has clipboard-interaction terminal escape sequences, but they're disabled by default in xterm. They're probably not implemented at all in PuTTY. This is probably for security reasons: you don't want a remote system to have full access to your clipboard.

I'm not sure if that's what vim's xterm_clipboard feature is supposed to use, anyway. My searching so far only turns up people complaining about it not being enabled, or talking about how to get a vim that has it enabled, not how it's actually implemented. The best I've found is this guide which mentions it, but doesn't say anything that would pin it down to escape sequences vs. X selection vs. X clipboard. (Yes, X11 has a selection and a separate clipboard. Some ways of copying only set one or the other.)


Vim's clipboard support talks directly to the X server. On a Linux desktop, with vim in a terminal (Konsole in my case) :"*dd does put the lines into the clipboard.

With

(unset DISPLAY; strace -s256 -o /dev/pts/18 vim some_file.txt)

vim doesn't have an X server to talk to. (pts18 is the tty of another terminal window.) I thought vim might use xterm escape sequences to set the clipboard, but it doesn't. There is no write(1, ...) system call with the whole region, so it's clearly not trying to use an escape sequence to put the region in the clipboard via xterm.

I ran this inside a Konsole with TERM=xterm, on Ubuntu 15.04. I also tried inside a real xterm.

Oh, xterm disables GetSelection/SetSelection by default. Maybe with this enabled, vim would try to use it? IDK if this helps, though, because PuTTY would also have to support it, which is unlikely.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜