如何在Vim中复制到剪贴板? [英] How to copy to clipboard in Vim?

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

问题描述

是否可以直接从Vim复制到剪贴板? yy 仅将内容复制到Vim的内部缓冲区中。我想复制到操作系统的剪贴板。在Vim中是否有这样的命令,或者您只能在Vim中提取东西?

Is it possible to copy to clipboard directly from Vim? yy only copies stuff to Vim's internal buffer. I want to copy to the OS's clipboard. Is there any such command in Vim or you can only yank stuff within Vim?

推荐答案

* 寄存器将执行此操作。在Windows中, + * 是等效的。在Unix中, + * 之间存在细微差别:

The * register will do this. In Windows, + and * are equivalent. In unix there is a subtle difference between + and *:


在Windows中,*和+寄存器
是等效的。对于X11系统,
有所不同。对于X11系统,
*是选择项,而+是剪切缓冲区(如剪贴板)。
http://vim.wikia.com/wiki/Accessing_the_system_clipboard

* 可能是大多数时候想要的,所以我使用 * ,因为它在两种环境下都能正常运行。

* is probably what you want most of the time, so I use * because it functions as I expect it to in both environments.

在Linux发行版中,您必须安装 vim-gtk (又名 gvim )首先获得剪贴板功能。这是因为非gtk vim通常在没有X11支持的情况下进行编译。

In Linux distros you have to install vim-gtk (aka gvim) first to gain clipboard functionality. This is because non-gtk vim is typically compiled without X11 support. This is to allow it to run on console only machines (often servers).

对于那些对于在拉动或放置时如何使用寄存器感到困惑的人,只需编写 然后是寄存器的名称。因此,要将某些内容复制到剪贴板寄存器,请键入 * y ,然后将其放入输入 * p (来源:Kyle Mathews)

And for those confused about how to use registers when yanking or putting, you merely write " then the name of the register. So for copying something to the clipboard register you type "*y and then to put you type "*p (credit: Kyle Mathews)

这篇关于如何在Vim中复制到剪贴板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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