是否可以直接从Vim复制到剪贴板?yy只把东西复制到Vim的内部缓冲区。我想复制到操作系统的剪贴板。在Vim中有这样的命令吗?或者你只能在Vim中提取东西?
当前回答
如果你正在使用GVim,你也可以设置guioptions+=a。这将触发自动复制到剪贴板的文本,您在视觉模式突出显示。 缺点:注意,高级剪贴板管理器(历史)将在这种情况下得到你所有的选择历史…
其他回答
Ubuntu - 2018年7月
使用寄存器“+”复制到系统剪贴板(即。+y而不是y)。
同样,您可以从“+”粘贴从系统剪贴板(即。"+p而不是p)。
您还必须确保编译的vim支持剪贴板。试一试:
vim --version | grep .xterm_clipboard -o
如果它是-xterm_clipboard(一个负号前缀),则不支持。
下面是一些使用支持剪贴板的vim工作版本进行交换的说明。
$ sudo apt-get purge vim
$ sudo apt-get autoremove (removes any extraneous vim dependency packages from system)
$ sudo apt-get install vim-gnome (or `sudo apt-get install vim-gtk3` for newer Ubuntu versions)
再次检查vim——version | grep .xterm_clipboard -o,您可以确认剪贴板现在是可用的(即。+ xterm_clipboard)
把设置剪贴板=未命名在你的vimrc。 选择你想要复制在视觉模式(按v进入)。 返回正常模式(按escape[esc]),按y复制。 如果你想从操作系统的剪贴板中粘贴一些东西,在Vim Normal模式下按p/ p。
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).
我有问题,因为我的vim不支持剪贴板:
vim --version | grep clip
-clipboard +insert_expand +path_extra +user_commands
+emacs_tags -mouseshape +startuptime -xterm_clipboard
我安装了vim-gnome(支持剪贴板),然后再次检查:
vim --version | grep clipboard
+clipboard +insert_expand +path_extra +user_commands
+emacs_tags +mouseshape +startuptime +xterm_clipboard
现在我可以分别使用“+y”和“+p”进行复制和粘贴。
到目前为止,我在MacOsX上使用键盘快捷键已经为此挣扎了几个月。 我知道问题不是关于使用键盘短裤。但这可能会对有同样担忧的人有所帮助。
我发现如果你不勾选:
View ->允许鼠标报告
从终端菜单,您将能够复制到剪贴板使用
Command + c
一次。