6

I want to know how to disable mouse wheel, however I found this and this question and I have tried put them to my .vimrc:

set mouse=""

map <ScrollWheelUp> <nop>
map <S-ScrollWheelUp> <nop>
map <ScrollWheelDown> <nop>
map <S-ScrollWheelDown> <nop>

But none of them will disable the mouse wheel, I still can use it to scrolling.

And I'm on Arch Linux, using vim 7.4 with gnome-terminal 3.16.2.

Community
  • 1
  • 1
Remi Guan
  • 21,506
  • 17
  • 64
  • 87

3 Answers3

6

It is probably a gnome-terminal problem and not a Vim one. With your .vimrc as it is, you can turn on and off the mouse wheel by issuing these commands in terminal

echo -e '\e[?1000h'
echo -e '\e[?1000l'

Edit: Previous answer doesn't work because gnome-terminal settings are overridden by settings of Cinnamon (in this case), and maybe also because the scrolling was done using a touchpad and not a mouse. It is possible to disable scrolling with help of Synclient (command line utility to configure and query Synaptics driver settings) putting

augroup scroll
    au!
    au  VimEnter * :silent !synclient VertEdgeScroll=0
    au  VimLeave * :silent !synclient VertEdgeScroll=1
augroup END

in your .vimrc.

This solution is not optimal for disabling scrolling even outside of Vim for as long as Vim runs.

ryuichiro
  • 3,765
  • 1
  • 16
  • 21
  • Hmm...`echo -e '\e[?1000h'` really disabled gnome-terminal mouse wheel. But first: when I try to scrolling, it will auto enter something like ``aE*`` or ``'B&'``. And I also can't click the terminal or select the text. And then, in vim it turned off the mouse wheel and wouldn't print these tings, but the *screen will scrolling*, I don't know how to explain this but however, it's not working. – Remi Guan Oct 03 '15 at 12:45
  • Wow, so... I don't know. You can also try to ask on https://bbs.archlinux.org/. Sorry it didn't help. – ryuichiro Oct 03 '15 at 12:56
  • No problem, actually I didn't know there is a way that can use command disable mouse wheel before :P – Remi Guan Oct 03 '15 at 13:00
  • 1
    O.k., at least something new :) – ryuichiro Oct 03 '15 at 13:01
  • Try to `set mouse=c`. – ryuichiro Oct 04 '15 at 22:28
  • Interesting things: It's disabled my mouse(actually I'm using touch pad) wheel scroll for my Chrome, menu, etc. But I still can use it for vim and gnome-terminal. But if I disable my touchpad wheel in the system setting center(I'm using Cinnamon Desktop) it will works. So I have to disable the scroll in the setting center, not in the vimrc? :) – Remi Guan Oct 04 '15 at 23:50
  • 1
    Yeah, it seems so :) Now just to figure out a method to automate disabling mouse wheel while you are working in Vim, and enabling it again while not. – ryuichiro Oct 05 '15 at 00:02
  • Maybe I need find how does that work :). And thanks, I'll accept your answer, but I think this answer could be better :P – Remi Guan Oct 05 '15 at 00:12
  • What about this one: `synclient VertEdgeScroll=0` (command in terminal)? Does it disable scrolling on the edge of touchpad in Vim? – ryuichiro Oct 05 '15 at 07:02
  • Yes it does, seems like what does the setting in system setting center do. And now I have an idea, I can create an alias like run this command when I start vim, and run `synclient VertEdgeScroll=1` when vim exit :) – Remi Guan Oct 05 '15 at 07:07
  • Yes, that is it. I edit my answer, maybe we can try vim-style solution :) – ryuichiro Oct 05 '15 at 07:08
  • Great, that is. Thank you so much! – Remi Guan Oct 05 '15 at 07:10
  • Your welcome! it was really nice collaboration:-) Now I am too tired but I will try to make my answer to look better later. – ryuichiro Oct 05 '15 at 07:13
4

Dell XPS and Ubuntu 16.04 makes using the scrollwheel with vim an unbearable experience where I can't type anything because my hand makes the cursor move every few characters!!

Add this to .vimrc to completely disable mouse scrolling:

set mouse=a

nmap <ScrollWheelUp> <nop>
nmap <S-ScrollWheelUp> <nop>
nmap <C-ScrollWheelUp> <nop>
nmap <ScrollWheelDown> <nop>
nmap <S-ScrollWheelDown> <nop>
nmap <C-ScrollWheelDown> <nop>
nmap <ScrollWheelLeft> <nop>
nmap <S-ScrollWheelLeft> <nop>
nmap <C-ScrollWheelLeft> <nop>
nmap <ScrollWheelRight> <nop>
nmap <S-ScrollWheelRight> <nop>
nmap <C-ScrollWheelRight> <nop>

imap <ScrollWheelUp> <nop>
imap <S-ScrollWheelUp> <nop>
imap <C-ScrollWheelUp> <nop>
imap <ScrollWheelDown> <nop>
imap <S-ScrollWheelDown> <nop>
imap <C-ScrollWheelDown> <nop>
imap <ScrollWheelLeft> <nop>
imap <S-ScrollWheelLeft> <nop>
imap <C-ScrollWheelLeft> <nop>
imap <ScrollWheelRight> <nop>
imap <S-ScrollWheelRight> <nop>
imap <C-ScrollWheelRight> <nop>

vmap <ScrollWheelUp> <nop>
vmap <S-ScrollWheelUp> <nop>
vmap <C-ScrollWheelUp> <nop>
vmap <ScrollWheelDown> <nop>
vmap <S-ScrollWheelDown> <nop>
vmap <C-ScrollWheelDown> <nop>
vmap <ScrollWheelLeft> <nop>
vmap <S-ScrollWheelLeft> <nop>
vmap <C-ScrollWheelLeft> <nop>
vmap <ScrollWheelRight> <nop>
vmap <S-ScrollWheelRight> <nop>
vmap <C-ScrollWheelRight> <nop>

You will no longer be able to copy selections using Ctrl+Shift+C using the Terminal's bindings, so you'll have to use "+y within vim to copy your selection into the system clipboard.

Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
0

Add this to your .vimrc to disable the mouse wheel in vim.

source: https://github.com/mintty/mintty/issues/170

" disable mouse wheel
let &t_ti.="\e[?7786l"
let &t_te.="\e[?7786h"
user3612690
  • 131
  • 1
  • 2