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

那么这可能吗?


当前回答

如果你在使用VI时遇到问题,另一种简单的复制整个文件的方法就是输入“cat filename”。它会将文件回显到屏幕上,然后你可以上下滚动并复制/粘贴。

其他回答

非常简单的办法:

如果你在Windows中,想要将整个文本复制到本地剪贴板,而不是你正在使用的远程服务器缓冲区,不需要任何额外的工具,只需:

放大,在屏幕上看到整个文件文本 用鼠标选择它们,然后右击复制到您的本地剪贴板

注1:现在在许多终端(如窗口终端)上,你可以用ctrl++/ctrl+-放大/缩小,用ctrl+0重置缩放大小

注2:如果你的vim是编号文件行,你可以:设置nonnumber

在Bill Joy的vi中没有“剪贴板”的概念,所以我不认为有内置的方法来做到这一点。

gVim的自动复制任何高亮显示到剪贴板的功能是最简单的或使用外部程序通过:!

对于Cygwin的vim,我使用

:%!putclip
u

也许Ubuntu有一个CLI应用程序,比如putclip??

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.

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

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

使用gg" * yy。

我不能用上面的答案复制文件,但我有腻子,我在Quora上找到了一个解决办法。

更改您的PuTTY会话设置,进入日志并将其更改为“可打印字符”。设置日志文件 做猫各自的文件 转到步骤#1中设置的文件,日志文件中将包含您的内容。

注意:它将该会话的所有打印字符复制到日志文件中,因此它最终会变得很大。在这种情况下,删除日志文件并删除目标文件,以便将特定文件的内容复制到您的计算机上。