是否可以直接从Vim复制到剪贴板?yy只把东西复制到Vim的内部缓冲区。我想复制到操作系统的剪贴板。在Vim中有这样的命令吗?或者你只能在Vim中提取东西?
当前回答
这个问题已经有很多答案了。我在添加我的方法,我觉得很快。
快速地,你可以按V (Shift + V)到激活可视模式。在可见模式下,可以使用j和k选择要复制的文本。选择后使用
"*y
现在,选定的文本被复制到剪贴板。
其他回答
In case you don't want to use any graphical interface for vim and you prefer to just stick with terminal emulator there may be a much simpler approach to this problem. Instead of using yank or anything like this, first take a look at documentation of terminal you use. I've been struggling with the same issue (trying to use +clipboard and xclip and so on) and in the end it turned out that in my terminal emulator it's enough to just press shift and select any text you want to copy. That's it. Quite simple and no need for messing with configuration. (I use urxvt by the way).
在Mac OSX上
复制所选部分:可视选择文本(正常输入v或v) 模式)和类型:w !pbcopy 复制整个文件:%w !pbcopy 从剪贴板粘贴:r !pbpaste
在大多数Linux发行版上,你可以替换:
用xclip -i -sel c或xsel -i -b拷贝上面的内容 使用xclip -o -sel -c或xsel -o -b进行Pbpaste 注意:如果这些工具(xsel和xclip)都没有预先安装在你的发行版上,你可以在回购中找到它们
Shift + Ctrl + C 如果你在Linux的图形模式,但首先你需要选择你需要复制什么。
我是一个Vim newby,但是,复制所有的文本到系统剪贴板(例如,如果你想把它粘贴到文字处理器或其他文本编辑器,如gedit,鼠标垫等…),在正常模式:
ggVGy
或者,更简单地说:
:%y
按照建议,我还安装了vim-gtk和put
设置剪贴板= unnamedplus
在我的。vimrc
一切都很正常
如果你只想复制文本的一部分,使用可视模式(v),选择你想要复制的文本,然后按y。
最后,我建议使用剪贴板程序,如Clipman(我最喜欢的)、Clipit、Parcellite或类似的程序。
(我在Debian Stretch Xfce中使用vim 8.0)
原谅我的英语!:-)
使用寄存器“+”复制到系统剪贴板(即。+y而不是y)。
同样,您可以从“+”粘贴从系统剪贴板(即。"+p而不是p)。