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

我可以使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.

其他回答

这适用于我:Ctrl+Shift+V

我在2017年年中的Macbook Pro上遇到了这个问题,我在iTerm2中运行vim作为我的主要开发环境。

正如其他答案所建议的那样,我运行vim——version并注意到它返回-clipboard,这意味着我的机器附带的vim版本没有使用clipboard选项进行编译。

vim的自制包似乎是用剪贴板选项编译的,所以对我的修复是:

运行brew install vim 添加set clipboard+= named到我的~/。vimrc文件 关闭并重新打开iTerm2

如果你有,试着从你的vimrc中删除这个: 设置鼠标=一个

它搅乱了粘贴功能。

有两种简单的方法。使您的文件处于插入模式和 1)按下鼠标中间的按钮(滚轮),或者 2) Ctrl + Shift + V

我认为这个问题应该有一个更客观和形象的答案:

进入粘贴模式

ESC :设置粘贴 按我 SHIFT +插入(将文本复制到剪贴板上)


退出粘贴模式

ESC :设置nopaste 按我

粘贴文本后,就可以再次输入了。