将 xterm 中运行的 Vim 7.2 中的文本复制到 Windows 剪贴板
我正在通过 putty 在 xterm 中使用 Vim 7.2 ,用 +xterm_clipboard 编译。我已将 set Clipboard=unnamed
放入 .vimrc 中,从我在其他线程中读到的内容来看,这应该将所有复制/删除内容放入系统剪贴板。然而,当我尝试将我复制的内容粘贴到记事本等 MS 应用程序时,它不起作用。
当我使用鼠标在 vim 中选择文本时,它会自动复制到系统(MS 剪贴板)。我希望在使用 3yy 等键盘命令时具有相同的功能。
谁能告诉我我做错了什么?
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 ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试
Try
如果你在本地运行 vim,那么两者都
可以工作,正如黑客所提到的。由于您已 sshed 到另一个盒子,这些只会将文本复制到您已 sshed 到的盒子的剪贴板。
你需要的是复制文本的putty方法,就是用鼠标高亮你要复制的文本。
不过,当 sshed 进入 vim 时,我通常使用 ALT + 鼠标突出显示(用于块选择),因为我通常会打开行号。
希望这有帮助!
If you were running vim locally, then either
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!
我试图弄清楚如何让 vim 进入 PuTTY(不涉及 xterm)以与 Windows 剪贴板交互。
到目前为止我的研究表明这是不可能的。 xterm 具有剪贴板交互终端转义序列,但它们在 xterm 中默认被禁用。它们可能根本没有在 PuTTY 中实现。这可能是出于安全原因:您不希望远程系统能够完全访问您的剪贴板。
无论如何,我不确定这是否是 vim 的
xterm_clipboard
功能应该使用的。到目前为止,我的搜索只发现人们抱怨它没有被启用,或者谈论如何获得启用它的 vim,而不是它的实际实现方式。我发现的最好的是 本指南 其中提到了它,但没有说任何将其固定为转义序列与 X 选择与 X 剪贴板的内容。 (是的,X11 有一个选择和一个单独的剪贴板。某些复制方式只能设置其中之一。)Vim 的剪贴板支持直接与 X 服务器对话。在 Linux 桌面上,在终端中使用 vim(在我的例子中是 Konsole)
:"*dd
确实会将这些行放入剪贴板。使用
vim 没有可以与之通信的 X 服务器。(< code>pts18 是另一个终端窗口的 tty。)我认为 vim 可能会使用 xterm 转义序列 来设置剪贴板,但它没有对整个区域进行 write(1, ...) 系统调用,因此它显然没有尝试使用。通过 xterm 将区域放入剪贴板的转义序列
我在 Konsole 中使用 TERM=xterm 运行,在 Ubuntu 15.04 上我也在真正的 xterm 中尝试过。
哦,xterm 默认禁用
GetSelection/SetSelection
,也许启用此功能后,vim 会尝试使用它(如果这有帮助的话),因为 PuTTY 也必须支持它,但这不太可能。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
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 nowrite(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 realxterm
.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.