Fandom

Vim Tips Wiki

Mouse wheel for scroll only - disable middle button paste

Redirected from VimTip564

1,624pages on
this wiki
Add New Page
Talk0 Share

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

Tip 564 Printable Monobook Previous Next

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>

CommentsEdit

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.


Also on Fandom

Random Wiki