在带有 xclip 的 vim 中,猛拉到剪贴板 [英] in vim with xclip, yank to clipboard

查看:20
本文介绍了在带有 xclip 的 vim 中,猛拉到剪贴板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Ubuntu 中有 vim 7.2 (-clipboard -xterm_clipboard ...).您可以看到它不支持剪贴板.所以我想编写一个小vim脚本,使用xclip工具将可视化选定的文本复制到剪贴板中.

I have vim 7.2 (-clipboard -xterm_clipboard ...) in Ubuntu. You can see that it's not support clipboard. So I want to write little vim script which copies visual selected text into the clipboard using xclip tool.

你知道 xclip 工具是这样工作的:

You know xclip tool works like that:

echo 'hello' | xclip -selection clipboard      #it copies 'hello' into clipboard

而且vim可以运行shell命令,所以想把可视化选中的文本复制到where而不是'hello',但是不知道xclip和vim怎么结合.你能帮我实现它吗.

And vim can run shell commands, so I want to copy visual selected text to where instead of 'hello', But I don't know how to combine xclip and vim. Can you help me to implement it.

感谢您的时间!

推荐答案

您是否使用发行版提供的 vim?如果是这样,vim-tinyvimvim-nox 包没有剪贴板支持,但它确实存在于 vim 中-lesstiffvim-gtkvim-gnome.

Are you using your distribution-provided vim? If so, the vim-tiny, vim, and vim-nox packages have no clipboard support, but it does exist in vim-lesstiff, vim-gtk, and vim-gnome.

如果你坚持按照自己的方式去做,

If you insist on doing it your way,

:'<,'>w !xclip

将当前选定的行发送到 xclip,并且

would send the current selected lines to xclip, and

:call system('xclip', @0)

会将最后一个 yank 发送到 xclip.

would send the last yank to xclip.

这篇关于在带有 xclip 的 vim 中,猛拉到剪贴板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆