与其他编辑器不同,vim将复制的文本存储在自己的剪贴板中。所以,对我来说,从网页复制一些文本并将其粘贴到当前的工作文件中是非常困难的。碰巧我必须打开gedit或手动输入它。

我可以使vim粘贴从和系统的剪贴板?


当前回答

你真正需要的是EasyClip。它会做到这一点,还有更多……

其他回答

你真正需要的是EasyClip。它会做到这一点,还有更多……

在Linux或Mac上使用Vim 8+,你现在可以简单地使用操作系统的本机粘贴(在Linux上ctrl+shift+V,在Mac上cmd+V)。插入模式时不要按i键。

它将粘贴操作系统剪贴板的内容,保留空格和制表符,而不添加自动缩进。它相当于旧的:set paste, i, ctrl+shift+V, esc,:set nopaste方法。

你甚至不再需要安装+clipboard或+xterm_clipboard vim特性。这个功能被称为“括号粘贴”。有关更多详细信息,请参见在将文本粘贴到vim时关闭自动缩进

When I use my Debian vim that is not integrated with Gnome (vim --version | grep clip # shows no clipboard support), I can copy to the clipboard after holding the Shift key and selecting the text with the mouse, just like with any other curses program. As I figured from a comment by @Conner, it's the terminal (gnome-terminal in my case) that turns off its mouse event reporting when it senses my Shift press. I guess curses-based programs can receive mouse events after sending a certain Escape sequence to the terminal.

Mac OS X:

运行vim——version | grep clipboard检查是否启用了剪贴板(使用+) 添加set clipboard= named到.vimrc 重启终端和vim

你可以通过gnome终端的快捷方式粘贴到vim中。 将文件置于插入模式并使用

Ctrl + Shift + v。

事先要记住

 :set paste 

避免弄乱缩进。