是否有任何方法复制所有行从打开的文件到VI编辑器剪贴板。我试过yG,但它没有使用剪贴板来存储这些行。
那么这可能吗?
是否有任何方法复制所有行从打开的文件到VI编辑器剪贴板。我试过yG,但它没有使用剪贴板来存储这些行。
那么这可能吗?
当前回答
在vim或它的选项卡中复制整个文件吗
y G
然后移动到一个标签和粘贴
p
并对整个文件进行删减使用
d G
其他回答
(回复@rshdev,并避免在OP的注释中使用@nelstrom +xterm_clipboard重新编译vim)
在Ubuntu 11上有一个叫xclip的程序,它的工作原理类似于putclip:
:%!xclip -sel clip
u
默认情况下不会安装。安装方法:
sudo apt-get install xclip
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.
:%y a把所有的内容放到vim的缓冲区中, 在命令模式下按下p键将会在你的光标当前所在的行之后粘贴被拖拽的内容。
在Bill Joy的vi中没有“剪贴板”的概念,所以我不认为有内置的方法来做到这一点。
gVim的自动复制任何高亮显示到剪贴板的功能是最简单的或使用外部程序通过:!
对于Cygwin的vim,我使用
:%!putclip
u
也许Ubuntu有一个CLI应用程序,比如putclip??
好吧,所有这些方法都很有趣,但是作为一个懒惰的程序员,我使用yank所有行通过使用数字+ y的组合
例如,你有一个总共78行的源代码文件,你可以这样做:
Gg获取第一行的游标 插入78 + y—>它在你的光标和当前行下面拉78行