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

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


当前回答

我尝试了上面的建议,但没有一个在我的环境中起作用。(Windows PuTTY通过ssh克隆)

你还可以在谷歌上搜索到: https://unix.stackexchange.com/questions/110684/copy-paste-into-sshd-vim-from-local-windows-clipboard

其中一条评论建议使用SHIFT+INSERT,它可以从我的桌面剪贴板粘贴到Vim的缓冲区中。Ctrl-C已经开始从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.

复制到操作系统剪贴板

在可视模式下选择文本,按“*y”

从操作系统剪贴板粘贴

按“* p

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

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

这将是你在vimrc中为此目的需要的行:

set clipboard+=unnamed  " use the clipboards of vim and win
set paste               " Paste from a windows or from vim
set go+=a               " Visual selection automatically copied to the clipboard

在设置:set clipboard= named之上,你应该使用mvim -v,如果你在终端上使用vim,你可以通过brew install macvim获得。应用程序在Mac OS X 10.9。默认vim不支持剪贴板选项。