Copying text outside of Vim with set mouse=a enabled

lyuba picture lyuba · Jan 5, 2011 · Viewed 104.6k times · Source

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:

enter image description here

Answer

François picture François · Jan 5, 2011

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)