是否可以直接从Vim复制到剪贴板?yy只把东西复制到Vim的内部缓冲区。我想复制到操作系统的剪贴板。在Vim中有这样的命令吗?或者你只能在Vim中提取东西?
当前回答
我的解决方案是安装额外的vim,包括剪贴板选项:
sudo apt-get install vim-gnome
其他回答
我在mac osx(10.15.3)和新的vim。我发现这太令人沮丧了,这里所有的答案都太复杂了,或者不适用于我的情况。我最终在两个方面得到了这个工作:
使用pbcopy的键映射:适用于mac附带的旧版本的vim。 将vmap ":w !pbcopy<CR><CR>添加到~/.vimrc中 现在您可以直观地选择并点击“(两个撇号)复制到剪贴板 安装新版本的vim,这样我就可以访问其他答案中最推荐的解决方案: 编译安装vim的别名vim=/usr/local/bin/vim(应该把这个添加到~/。Bashrc或同等语言) 现在您可以直观地选择并点击“+yy复制到剪贴板
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).
@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.
在linux gnome (ubuntu, xubuntu等)安装vim-gnome,你将能够使用VISUAL选择,然后正常按Ctrl + C,用Ctrl + V粘贴到其他应用程序
sudo apt install vim-gnome
Shift + Ctrl + C 如果你在Linux的图形模式,但首先你需要选择你需要复制什么。
推荐文章
- 强迫自己掌握vi的最好方法是什么?
- 如何回到行之前编辑的最后一个在Vim?
- 如何跳转到一个特定的人物在vim?
- 如何删除一个大的文本块而不计算行?
- 复制文本到剪贴板与iOS
- 如何从远程SSH会话发送数据到本地剪贴板
- 在Vim/Vi中,如何将光标移动到前一个单词的末尾?
- 如何在vim中自动删除尾随空格
- 为什么Vim使用~扩展名保存文件?
- 如何在Vim或Linux中将空格转换为制表符?
- 我如何使用vimdiff来解决git合并冲突?
- 在Vim中删除当前缓冲区的文件名/路径
- Git在终端提交时打开VIM,但无法返回终端
- 请参阅编辑器中的换行符和回车
- 如何在NERDTree中显示隐藏文件(以句点开始)?