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


当前回答

对于一些国际键盘,您可能需要按“+空格获得a”。

所以在这种情况下,你必须按“空格+y”或“空格*y”

其他回答

我不能复制到剪贴板的系统中,因为我的~/中有这个。vimrc文件:

 if has('mouse')
   set mouse=a
 endif

但如果你接下来添加这一行,它将允许你简单地按Ctrl+c将你所选择的任何东西放入剪贴板。

vmap <C-c> "+y

原始讨论和更多详细信息:启用set mouse=a从vim中复制文本

对于一些国际键盘,您可能需要按“+空格获得a”。

所以在这种情况下,你必须按“空格+y”或“空格*y”

对于OSX,就像上面的10342个答案所表明的那样,你需要确保vim支持剪贴板功能,并且OSX预发布的那个不支持剪贴板,如果你运行 酿造安装vim它将工作。

除了运行vi仍然会让你运行预先发布的OSX版本,而不是你从brew安装的版本。

为了解决这个问题,我简单地将我的vim命令别名为酿造版本,而不是OSX的默认版本:

alias vim="/usr/local/Cellar/vim/8.0.1100_1/bin/vim"

现在我是金的

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

使用寄存器“+”复制到系统剪贴板(即。+y而不是y)。

同样,您可以从“+”粘贴从系统剪贴板(即。"+p而不是p)。