Vim Tips Wiki
(Fix typos)
(Remove html character entities)
Line 17: Line 17:
   
 
If you have a scrollwheel and often accidentally paste text, you can use these mappings to disable the pasting with the middle mouse button:
 
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>
+
:map <MiddleMouse> <Nop>
:imap &lt;MiddleMouse&gt; &lt;Nop&gt;
+
:imap <MiddleMouse> <Nop>
   
 
To revert to the original setting for middle button click:
 
To revert to the original setting for middle button click:
:unmap &lt;MiddleMouse&gt;
+
:unmap <MiddleMouse>
:iunmap &lt;MiddleMouse&gt;
+
:iunmap <MiddleMouse>
   
 
==Comments==
 
==Comments==
Line 28: Line 28:
   
 
Alternatively, instead of simply ignoring it, make it the same as a left click with:
 
Alternatively, instead of simply ignoring it, make it the same as a left click with:
noremap &lt;MiddleMouse&gt; &lt;LeftMouse&gt;
+
noremap <MiddleMouse> <LeftMouse>
   
 
Also with noremap!, and the whole 2-,3-,etc. list above.
 
Also with noremap!, and the whole 2-,3-,etc. list above.

Revision as of 08:56, 29 September 2008

Tip 564 Printable Monobook Previous Next

created September 26, 2003 · complexity basic · author Girish Gajwani · version 5.7


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?


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.