是否有任何方法复制所有行从打开的文件到VI编辑器剪贴板。我试过yG,但它没有使用剪贴板来存储这些行。
那么这可能吗?
是否有任何方法复制所有行从打开的文件到VI编辑器剪贴板。我试过yG,但它没有使用剪贴板来存储这些行。
那么这可能吗?
当前回答
你应该把文本拉到*或+寄存器:
加贝*孝媛”
解释:
Gg将光标移到文件的第一个字符 *y从第一行开始执行yank命令到寄存器*,直到… G到文件的末尾
其他回答
gVim:
:set go=a
ggVG
看:help go-a:
'a' Autoselect: If present, then whenever VISUAL mode is started,
or the Visual area extended, Vim tries to become the owner of
the windowing system's global selection. This means that the
Visually highlighted text is available for pasting into other
applications as well as into Vim itself. When the Visual mode
ends, possibly due to an operation on the text, or when an
application wants to paste the selection, the highlighted text
is automatically yanked into the "* selection register.
Thus the selection is still available for pasting into other
applications after the VISUAL mode has ended.
If not present, then Vim won't become the owner of the
windowing system's global selection unless explicitly told to
by a yank or delete operation for the "* register.
The same applies to the modeless selection.
虽然上面的许多答案都很出色,但没有一个解决方案适合我,因为我使用的是Ubuntu 16.04附带的默认VIM安装,并且默认没有安装剪贴板选项。我还想把文本粘贴到一个外部程序中。
解决方案:Ubuntu的默认终端允许你通过点击编辑然后全选来高亮显示全部内容。
我在PowerShell中使用Vim,当我需要将一小段代码复制到windows剪贴板时;
我使用:set nonnumber来删除行号,然后用游标和右键单击在视觉上选择代码。然后我用Ctrl + V将它粘贴到任何我想要的地方。
我知道这个问题应该用十年时间来解决,但前两个答案对我来说不管用,所以我继续研究。在Redhat(远程服务器)- Windows 10(本地机器)上,如果你不能用鼠标选择全部内容,你就会卡住,因为通常的副本在远程和本地机器剪贴板之间不起作用。
因此,要在远程Linux上复制并粘贴到本地Windows上,请使用*指定主缓冲区并执行一个漂亮的双重yank
使用gg" * yy。
好吧,所有这些方法都很有趣,但是作为一个懒惰的程序员,我使用yank所有行通过使用数字+ y的组合
例如,你有一个总共78行的源代码文件,你可以这样做:
Gg获取第一行的游标 插入78 + y—>它在你的光标和当前行下面拉78行