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

查看:22
本文介绍了如何在 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

Under Windows, the * and + registers are equivalent. For X11 systems, though, they differ. For X11 systems, * is the selection, and + is the cut buffer (like clipboard). 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).

对于那些在 yanking 或 put 时对如何使用寄存器感到困惑的人,您只需编写 " 然后是寄存器的名称.因此,要将某些内容复制到剪贴板寄存器,请键入 "*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天全站免登陆