是否可以直接从Vim复制到剪贴板?yy只把东西复制到Vim的内部缓冲区。我想复制到操作系统的剪贴板。在Vim中有这样的命令吗?或者你只能在Vim中提取东西?
当前回答
你可以在这里找到答案 拱维基
Linux: 首先,你必须通过安装在你的vim版本中启用剪贴板 gvim。
接下来,您必须将这一行放到.vimrc文件中。
设置剪贴板= unnamedplus
其他回答
@Jacob Dalton has mentioned this in a comment, but nobody seems to have mentioned in an answer that vim has to be compiled with clipboard support for any of the suggestions mentioned here to work. Mine wasn't configured that way on Mac OS X by default and I had to rebuild vim. Use this the command to find out whether you have it or not vim --version | grep 'clipboard'. +clipboard means you're good and the suggestions here will work for you, while -clipboard means you have to recompile and rebuild vim.
总结一下,让新手更容易上手,
复制当前行,在命令模式输入:
"*yy
要复制整个文件/缓冲区,在命令模式下,首先通过gg转到开头,然后键入
"*yG
如上所述,这需要vim——version中的+clipboard,这表示支持剪贴板,-clipboard表示不支持。
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).
这个问题已经有很多答案了。我在添加我的方法,我觉得很快。
快速地,你可以按V (Shift + V)到激活可视模式。在可见模式下,可以使用j和k选择要复制的文本。选择后使用
"*y
现在,选定的文本被复制到剪贴板。
如果您通过putty连接到Unix系统,那么按照以下步骤复制文件的内容
突出显示要复制的文本(您将能够逐页复制) 按ctrl+c(它将复制文本到剪贴板 粘贴任何外部编辑器 完成