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

那么这可能吗?


当前回答

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.

其他回答

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

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

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

在vim或它的选项卡中复制整个文件吗

y G 

然后移动到一个标签和粘贴

p

并对整个文件进行删减使用

d G

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

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

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

在Mac

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

Ubuntu 12

你可以尝试安装vim-gnome包:

sudo apt-get install vim-gnome

我尝试了一下,因为vim——version告诉我它将禁用xterm_clipboard标志(由-指示),这是使用剪贴板功能所必需的。

在Ubuntu 12上安装vim-gnome包的>也安装了一个基于控制台的vim版本,该版本启用了这个选项(xterm_clipboard标志前的+表示)

在Arch Linux上

出于同样的原因,您可以安装vim-clipboard。

如果运行neovim,则应该安装xclip(参见help clipboard-tool)