Copying text outside of Vim with set mouse=a enabled
After enabling set mouse=a
, text copied inside of Vim will not paste outside of Vim. Does anybody know of a way to fix this?
Here, selecting text with the mouse turns on visual mode and disables the Copy
option in the popup menu:
Press shift while selecting with the mouse. This will make mouse selection behave as if mouse=a
was not enabled.
Note: this trick also applies to "middle button paste": if you want to paste in vim text that was selected outside, press shift while clicking the middle button. Just make sure that insert mode is activated when you do that (you may also want to :set paste
to avoid unexpected effects).
OS X (mac): hold alt/option while selecting (source)
Use "+y. You shouldn't be using the terminal's copy command anyway, because that copies what the terminal sees instead of the actual content.
You could map it like this:
:vmap <C-C> "+y
And then highlight something with the mouse and press Control-C to copy it.
This feature only works when Vim has been compiled with the +xterm_clipboard
option. Run vim --version
to find out if it has.
而不是在.vimrc中set mouse=a
使用set mouse=r
上一篇: Vim:将选择复制到OS X剪贴板