是否可以直接从Vim复制到剪贴板?yy只把东西复制到Vim的内部缓冲区。我想复制到操作系统的剪贴板。在Vim中有这样的命令吗?或者你只能在Vim中提取东西?
当前回答
把设置剪贴板=未命名在你的vimrc。 选择你想要复制在视觉模式(按v进入)。 返回正常模式(按escape[esc]),按y复制。 如果你想从操作系统的剪贴板中粘贴一些东西,在Vim Normal模式下按p/ p。
其他回答
Shift + Ctrl + C 如果你在Linux的图形模式,但首先你需要选择你需要复制什么。
在vimrc文件中,可以指定自动使用系统剪贴板进行复制和粘贴。
macOS和Windows设置:
set clipboard=unnamed
Linux set (vim 7.3.74+):
set clipboard=unnamedplus
注意:您可能需要使用最新版本的Vim才能工作。
http://vim.wikia.com/wiki/Accessing_the_system_clipboard
对于Mac OS X,在终端中:
运行vim——version | grep clipboard检查是否启用了剪贴板(使用+)
将下面的代码添加到.vimrc文件中
如果有(“剪贴板”) Set clipboard= named "复制到系统剪贴板 If has("unnamedplus") "X11支持 设置剪贴板+ = unnamedplus endif endif
重启终端和vim
参考:在Mac OS X上设置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).
在我的实例中,用鼠标高亮显示(单击和拖动)选择文本会导致vim进入可视模式。
在mac上,最简单的解决方案是使用fn +鼠标点击和拖动,以避免进入可视模式。
如果您希望在默认情况下避免这种行为,可以编辑vimrc
推荐文章
- 强迫自己掌握vi的最好方法是什么?
- 如何回到行之前编辑的最后一个在Vim?
- 如何跳转到一个特定的人物在vim?
- 如何删除一个大的文本块而不计算行?
- 复制文本到剪贴板与iOS
- 如何从远程SSH会话发送数据到本地剪贴板
- 在Vim/Vi中,如何将光标移动到前一个单词的末尾?
- 如何在vim中自动删除尾随空格
- 为什么Vim使用~扩展名保存文件?
- 如何在Vim或Linux中将空格转换为制表符?
- 我如何使用vimdiff来解决git合并冲突?
- 在Vim中删除当前缓冲区的文件名/路径
- Git在终端提交时打开VIM,但无法返回终端
- 请参阅编辑器中的换行符和回车
- 如何在NERDTree中显示隐藏文件(以句点开始)?