Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Is it possible to copy to clipboard directly from Vim?

(是否可以直接从Vim复制到剪贴板?)

yy only copies stuff to Vim's internal buffer.

(yy只复制东西给Vim的内部缓冲区。)

I want to copy to the OS's clipboard.

(我想复制到操作系统的剪贴板。)

Is there any such command in Vim or you can only yank stuff within Vim?

(在Vim中有没有这样的命令,或者你只能在Vim中猛拉东西?)

  ask by Hari Menon translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
491 views
Welcome To Ask or Share your Answers For Others

1 Answer

The * register will do this.

(*寄存器将执行此操作。)

In Windows, + and * are equivalent.

(在Windows中, +*是等价的。)

In unix there is a subtle difference between + and * :

(在unix中, +*之间存在细微差别:)

Under Windows, the * and + registers are equivalent.

(在Windows下,*和+寄存器是等效的。)

For X11 systems, though, they differ.

(但是,对于X11系统,它们有所不同。)

For X11 systems, * is the selection, and + is the cut buffer (like clipboard).

(对于X11系统,*是选择,+是剪切缓冲区(如剪贴板)。)

http://vim.wikia.com/wiki/Accessing_the_system_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.

(*可能是你大多数时候想要的,所以我使用*因为它在两种环境中都能像我期望的那样运行。)

In Linux distros, for some reason, you have to install vim-gtk first to gain clipboard functionality.

(在Linux发行版中,出于某种原因,您必须首先安装vim-gtk才能获得剪贴板功能。)

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

(对于那些在yanking或put时如何使用寄存器感到困惑的人,你只需要写"然后是寄存器的名称。所以为了将某些东西复制到剪贴板寄存器,你输入"*y然后给你输入"*p)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...