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

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


当前回答

Shift +右键->粘贴

对我有用吗

其他回答

对于一些国际键盘,您可能需要按“+空格获得a”。

所以在这种情况下,你必须按“空格+y”或“空格*y”来复制。

空格+p或者空格*p来粘贴。

如果你使用鼠标,首先做

 :set paste 

然后右击鼠标,缓冲区中的内容将被粘贴

对我来说,这个配置适用于复制和粘贴

" copy and paste
vmap <C-c> "+yi
vmap <C-x> "+c
vmap <C-v> c<ESC>"+p
imap <C-v> <ESC>"+pa

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 OSX中使用vim,不幸的是它带有旧版本,并且不符合剪贴板选项。幸运的是,自制程序可以很容易地解决这个问题。

安装vim:

Brew install vim -with-lua -with-override-system-vim

安装vim的GUI版本:

Brew install macvim -with-lua -with-override-system-vim

重启终端生效。

将下面的行追加到~/.vimrc 设置剪贴板=不知名的

现在,您可以用yy在vim中复制该行,并在系统范围内粘贴它。