How to set vim to support mouse scrolling, but keep text selection on left click

mousescrollingvim

I would like to scroll my files opened in vim using mousewheel, but at the same time using the left mouse button to select text into clipboard.

Setting :set mouse=nicr (or :set mouse=a) will only accomplish the former, doing :set mouse= will only accomplish the latter.
There is a similar question – Vim enable mouse scroll only – not cursor positioning – already on SU, but the answer suggests to disable left click functionality altogether, contrary to my needs.

I work with MATE terminal (xterm).

Best Answer

Vim should be able to connect to the X server and allow you to highlight text and have it copied into the X selection buffer. Is the letter "a" in your 'guioptions' setting?

:verbose set guioptions?

(Include the question mark as part of the command.)

If Vim says that option is not supported it means you have a lighter version of Vim installed. Check the output of ":version" and if you see a "-" in front of "mouse_xterm" or in front of "x11" you need a different version of Vim.

Most Linux distributions make a few versions of Vim available, but often just install the lighter version by default. Check your package manager's list and find the appropriate package. Look for something like "vim-gtk" or "vim-enhanced".

Alternatively almost all xterm type emulators let you hold down shift to allow the terminal to "take control" of the mouse highlighting instead of sending mouse events to the application running in the terminal.

Related Question