VI编辑器:将整个文件发送到剪贴板(特定于OS X) [英] VI Editor : Yank the entire file to clipboard (specific to OS X)
问题描述
有什么方法可以在VI编辑器中将所有行从文件复制到剪贴板.我从SO的先前文章中尝试过*yG
,+yG
,"+yG
和:%y+
,但是在OS X中没有任何作用.
Is there any way to copy all lines from a file to clipboard in VI editor. I have tried *yG
, +yG
, "+yG
and :%y+
from previous posts in SO, but nothing works in OS X.
推荐答案
Mac OS X随附的默认Vim /usr/bin/vi[m]
未与剪贴板支持一起编译.
The default Vim shipped with Mac OS X, /usr/bin/vi[m]
, isn't compiled with clipboard support.
您有三个选择:
-
从命令行使用
pbcopy
,而不使用Vim
use
pbcopy
from the command line, without using Vim
$ cat filename | pbcopy
使用Vim中的pbcopy
use pbcopy
from Vim
:%w !pbcopy
使用剪贴板支持获取自己的Vim
您可以通过 MacPorts 或通过下载 MacVim 或通过构建
You can do that through MacPorts or Homebrew, by downloading MacVim or by building from the source.
使用y
使用特定寄存器的正确方法是"{register}y
.
Also the correct way to use a specific register with y
is "{register}y
.
请参见终端中的$ man pbcopy
以及Vim中的:help clipboard
和:help !
.
See $ man pbcopy
in your terminal and :help clipboard
and :help !
in Vim.
这篇关于VI编辑器:将整个文件发送到剪贴板(特定于OS X)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!