gvim:轻松复制到系统剪贴板 [英] gvim: Easy copying into system clipboard
问题描述
我在Ubuntu 10.10上使用gVim.我想将文本复制(粘贴)到系统剪贴板,以便复制的文本可在其他应用程序中使用.
I am using gVim on Ubuntu 10.10. I want to copy (yank) text to the system clipboard, so that the copied text is available in other applications.
这与"+y
一起使用.但我想让它与y
一起使用.
This works with "+y
. But I want to have it working with y
.
我尝试将y
映射到"+y
,但是yy
不再起作用(因为它会生成"+y"+y
).
I have tried to map y
to "+y
but then yy
doesn't work anymore (since it produces "+y"+y
).
我也尝试过
:set clipboard=unnamed
但这仅在另一个方向起作用:我可以使用p
粘贴系统剪贴板中的文本.
I have also tried
:set clipboard=unnamed
but this works only the other direction: Text in the system clipboard I can paste with p
.
推荐答案
您尝试使用以下命令进行映射:
Did you try to map with this command:
noremap y "+y
?此映射包含一个严重的错误:它在普通,可视和操作员待定模式下映射y
,而您仅需要普通和可视模式.使用以下内容:
? This mapping contains a serious mistake: it maps y
in normal, visual and operator-pending modes, while you need only normal and visual modes. Use the following:
nnoremap y "+y
vnoremap y "+y
也可以尝试set clipboard=unnamedplus
(至少需要vim-7.3.74). set clipboard=unnamed
可以在两个方向上工作,但是它设置的鼠标"(*
)寄存器与剪贴板寄存器(+
)不同.
Also try set clipboard=unnamedplus
(it requires at least vim-7.3.74). set clipboard=unnamed
works in both directions, but it sets «mouse» (*
) register which is different from clipboard register (+
).
这篇关于gvim:轻松复制到系统剪贴板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!