是否可以直接从Vim复制到剪贴板?yy只把东西复制到Vim的内部缓冲区。我想复制到操作系统的剪贴板。在Vim中有这样的命令吗?或者你只能在Vim中提取东西?


当前回答

以上这些在我的windows笔记本电脑上都不起作用。

Ctrl+C可以用于复制。但我需要 Shift+插入到粘贴!

(一个很好的理由,总是有一个笔记本电脑,可以随时插入,而不需要按第二个键)

其他回答

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).

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)

Shift + Ctrl + C 如果你在Linux的图形模式,但首先你需要选择你需要复制什么。

仅在ubuntu终端下的vim中,

在vim中按shift +鼠标拖动选择文本,然后在终端上按CTRL + shift + c

然后在其他编辑器上按CTRL + v

如果你的vim编译时没有+xterm_clipboard选项,就像Debian和Ubuntu中默认的那样,你可以将选择或整个缓冲区输送到处理桌面剪贴板的外部程序。对于xclip(您可能需要在前面安装它),命令将是:w !xclip -sel clip