是否可以直接从Vim复制到剪贴板?yy只把东西复制到Vim的内部缓冲区。我想复制到操作系统的剪贴板。在Vim中有这样的命令吗?或者你只能在Vim中提取东西?
当前回答
你可以在这里找到答案 拱维基
Linux: 首先,你必须通过安装在你的vim版本中启用剪贴板 gvim。
接下来,您必须将这一行放到.vimrc文件中。
设置剪贴板= unnamedplus
其他回答
如果您通过putty连接到Unix系统,那么按照以下步骤复制文件的内容
突出显示要复制的文本(您将能够逐页复制) 按ctrl+c(它将复制文本到剪贴板 粘贴任何外部编辑器 完成
对于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).
也许有人会觉得有用。我想要独立于X剪贴板,并且仍然能够在两个运行的vims之间复制和粘贴一些文本。这段小代码将所选文本保存在temp.txt文件中以供复制。将下面的代码放入您的.vimrc中。使用CTRL-c CTRL-v来完成这项工作。
cp /dev/null ~/temp.txt && cat > ~/temp.txt
Noremap:r !cat ~/temp.txt
Shift + Ctrl + C 如果你在Linux的图形模式,但首先你需要选择你需要复制什么。