Long time vim user looking for some advice on this, tried searching the
web to no avail. I am using CentOS 6 and vim 7.2.411.
My issue: In vim, I am in INSERT mode, my cursor is where I want it to be
for a PASTE operation, but when I press the middle mouse button (which in
my case is a scroll wheel) to do the paste the wheel moves inadvertently
and I end up pasting somewhere else, not in the place where my cursor
was when I entered INSERT mode.
Is there a way to configure vim so that the mouse scroll wheel/middle
mouse button is disabled when in INSERT mode?
Outside of insert mode the mouse scroll is a great feature, so I only
want to disable it when in insert mode.
Thanks for any help,
> The following mappings seem to do the trick...
I know the OP is on CentOS, but FWIW the mappings don't work on Windows; the mouse wheel handling is hard-coded there.
Regards, John Little
That's not right, it's "<ScrollWheelUp>", the word "Mouse" is not used, but if it worked, I presume that's a mistake in your post.
> which looks like this on my screen :nmap ^[OA <nop>
> and of course the MouseScrollWheelDown (which is ^[OB ) too.
I don't understand that, or what you are doing. It should look exactly like
:inoremap <ScrollWheelDown> <nop>
:inoremap <ScrollWheelUp> <nop>
on your screen, no control sequences. Just fired up gnome-terminal (for the first time in several years, it doesn't play well with KDE) and those exact commands worked.
Also, if I use control-V to find what gnome-terminal sends for the scroll wheel I get something like
^[[<65;7;26M
and
^[[<64;15;28M
(they vary depending on something, maybe the screen position, so you couldn't map them that way).
^[OA and ^[OB are the sequences for up arrow and down arrow. If you are getting those when you use the scroll wheel, then that's your problem, something is changing the scroll actions to arrow key presses. To check that out, in vim in insert mode press ctrl-v then move the scroll wheel one notch.
(Interestingly, I checked out xterm and konsole; xterm is the same or similar to gnome-terminal, but konsole sends ^[[M`P6 and ^[[MaP6. What the second and third numbers are in the xterm and gnome-terminal sequences, and how vim sorts it all out, has me perplexed.)
Regards, John Little
> When you start gnome-terminal in KDE, does it get narrower in small
> steps until it is about 20 columns wide?
Yes. I gathered that the gnome 3 people say kwin acts on a misinterpretation of some standard, and their way is the only right way to do things. Very Gnome 3-ish. Also, I'm a fan of a 4 or 5 Hz cursor blink, and to persuade gnome-terminal to blink quickly the gnome settings daemon has to be running, and I used to do that, but I couldn't get the Gnome 3 one to run without the rest of Gnome, which I don't want. I found how to quicken the cursor in konsole (it's a qt4 setting) and quite like it now.
Regards, John Little
They demonstrate that he is using
:inoremap <ScrollWheelDown> <nop>
but as I suggested be checked out, Glenn is getting ^[OA and ^[OB arrow key sequences when the mouse wheel is used.
What could be causing this? I have no idea, other than I'm told it's possible using easystroke, an X mouse gesture tool. His CentOS is
Red Hat Enterprise Linux Workstation release 6.5 (Santiago)
Regards, John Little
Hi John,
Have you found any solution of this issue, I'm still suffering from this on Ubuntu 16.04: my mouse scroll up/down are binded to keyboard arrow up/down. My terminal is konsole.
It would be greatly appreciated if you have some clue of why this happened.
Best,
Clark