created 2003 · complexity basic · author Girish Gajwani · version 6.0
I have had a problem when using the mousewheel for scrolling. I occasionally press the wheel and it pastes text in the clipboard's "*" register at the place where the scroll wheel was pressed accidentally. This has been a constant irritation.
The workaround is documented at :help <MiddleMouse>, which includes the following information.
If you have a scrollwheel and often accidentally paste text, you can use these mappings to disable the pasting with the middle mouse button:
:map <MiddleMouse> <Nop> :imap <MiddleMouse> <Nop>
To revert to the original setting for middle button click:
:unmap <MiddleMouse> :iunmap <MiddleMouse>
Comments[]
While at it, take care also of 2-MiddleMouse, 3-MiddleMouse and (oh, humanity!) 4-MiddleMouse (that's for middle double clicks and triple and ...).
Alternatively, instead of simply ignoring it, make it the same as a left click with:
noremap <MiddleMouse> <LeftMouse>
Also with noremap!, and the whole 2-,3-,etc. list above.
These tips are helpful in stopping an accidental *single* click, but two or more clicks in same location (such as the button being pressed on by a book) will still cause a paste to occur. Anyone know why?
The solution is to add the following as well, to handle double-click, triple-click, and quadruple-click:
:map <2-MiddleMouse> <Nop> :imap <2-MiddleMouse> <Nop> :map <3-MiddleMouse> <Nop> :imap <3-MiddleMouse> <Nop> :map <4-MiddleMouse> <Nop> :imap <4-MiddleMouse> <Nop>
I find it easier to hold down the Ctrl key since I have nothing mapped to Ctrl-Middle. And then the middle mouse button still works according to my creaky old X-windows-originated intuitions.