Xin*_*nus 520 vi vim keyboard-shortcuts editor
有没有办法在VI编辑器中将所有行从打开文件复制到剪贴板.我试过,yG但它没有使用剪贴板来存储这些行.
那有可能吗?
Roo*_*ook 650
使用:
:%y+
猛拉所有线路.
说明:
%
引用下一个命令来处理所有行y
猛拉那些线+
复制到系统剪贴板注:在Windows中,+
而且*
是等效的看到这个答案.
CMS*_*CMS 589
您应该将文本拉到*
或+
注册:
gg"*yG
说明:
gg
将光标移动到文件的第一个字符"*y
*
从第一行开始向寄存器发出一个yank命令,直到......G
去文件的末尾Bri*_*ian 79
在Mac上
复制所选部分:直观地选择文本(类型v
或V
在正常模式下)并键入:w !pbcopy
复制整个文件 :%w !pbcopy
从剪贴板过去 :r !pbpaste
Tor*_*dek 52
剪贴板是缓冲区+.要复制到剪贴板,请执行"+y和[移动].
所以,gg"+yG会复制整个文件.
同样,要从剪贴板粘贴, "+p
Zac*_*ack 41
如果您在使用VI时遇到问题,另一种复制整个文件的简单方法就是输入"cat filename".它会将文件回显到屏幕,然后您可以向上和向下滚动并复制/粘贴.
小智 30
这就是我整理文件的方法:
ggVGy
Run Code Online (Sandbox Code Playgroud)
Ste*_*tew 10
(回复@rshdev,并避免在OP的评论中每个@nelstrom使用+ xterm_clipboard重新编译vim)
有一个名为xclip的程序,就像在Ubuntu 11上使用putclip一样:
:%!xclip -sel clip
u
Run Code Online (Sandbox Code Playgroud)
它没有默认安装.安装,使用:
sudo apt-get install xclip
Run Code Online (Sandbox Code Playgroud)
在Ubuntu 12上
您可能会尝试安装该vim-gnome
软件包:
sudo apt-get install vim-gnome
Run Code Online (Sandbox Code Playgroud)
我试过了,因为vim --version
告诉我它会禁用标志xterm_clipboard(用-表示),这是使用剪贴板功能所必需的.
- > 在Ubuntu 12上安装vim-gnome软件包还安装了一个基于控制台的vim版本,启用了此选项(在xterm_clipboard标志之前用+表示)
在Arch Linux上
你可以安装vim-clipboard
相同的原因.
小智 8
请复制 vim 或其选项卡中的整个文件
y G
Run Code Online (Sandbox Code Playgroud)
然后移动到一个选项卡并粘贴
p
Run Code Online (Sandbox Code Playgroud)
并剪切整个文件使用
d G
Run Code Online (Sandbox Code Playgroud)
:set go=a
Run Code Online (Sandbox Code Playgroud)
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.
Run Code Online (Sandbox Code Playgroud)
如果您在可视模式下使用Vim,则标准剪切和粘贴键也适用,至少在Windows中是这样.
至少在Ubuntu终端(Gnome)下,标准副本也可以使用(CTRLSHIFTC虽然似乎没有标准的键盘快捷键select all
(除了ALTE后面跟A).
小智 5
我尝试了一些人们上面提到过的命令.没有用.然后我抓住了最简单的一切.
步骤1:vi <filename>
步骤2:右键单击Putty窗口的标题栏
步骤3:选择"清除回滚"(以避免复制其余的SSH会话)
步骤4:再次右键单击并选择"全部复制到剪贴板".