是否有任何方法复制所有行从打开的文件到VI编辑器剪贴板。我试过yG,但它没有使用剪贴板来存储这些行。

那么这可能吗?


当前回答

我知道这个问题应该用十年时间来解决,但前两个答案对我来说不管用,所以我继续研究。在Redhat(远程服务器)- Windows 10(本地机器)上,如果你不能用鼠标选择全部内容,你就会卡住,因为通常的副本在远程和本地机器剪贴板之间不起作用。

因此,要在远程Linux上复制并粘贴到本地Windows上,请使用*指定主缓冲区并执行一个漂亮的双重yank

使用gg" * yy。

其他回答

在Mac

复制所选部分:可视选择文本(正常输入v或v) 模式)和类型:w !pbcopy 复制整个文件:%w !pbcopy 过去从剪贴板:r !pbpaste

我尝试了上面人们提到的一些命令。没有工作。 然后我找到了其中最简单的一个。

步骤1:vi <filename> 第二步:右键单击Putty窗口的标题栏 步骤3:选择“清除屏幕”(以避免复制SSH会话的其余部分) 第四步:再次右键单击并选择“复制所有到剪贴板”。

如果在可视模式下使用Vim,标准的剪切和粘贴键也适用,至少在Windows中是这样。

CTRLA表示“标记整个文件”。 CTRLC表示“复制所选内容”。 ESC表示“取消选择,所以你的下一个按键不会替换整个文件:-)

至少在Ubuntu终端(Gnome)下,标准副本也可以工作(CTRLSHIFTC,尽管似乎没有一个标准的键盘快捷键用于全选(除了ALTE后面跟着a)。

您可以使用“cat”命令打开文件,并使用鼠标复制

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.