Xfce Forum

Sub domains
 

You are not logged in.

#1 2025-09-30 01:56:52

cyberplunk
Member
Registered: 2023-01-13
Posts: 28
LinuxFirefox 142.0

[Solved] Disabling Scrolling in Vim

When using Vim in xfce4-terminal 1.1.4, I'd like to turn off mouse wheel scrolling. Specifically, I'd like to turn off only mouse wheel scrolling and only for Vim. Various online suggestions say that I should insert the following into ~./vimrc:

set mouse=
set ttymouse=

or

set mouse-=a

or

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

Unfortunately, none of these seem to work. I welcome any suggestions the community has.

Added later 05 min 33 s:
And as soon as I posted, I figured out a solution:

set mouse=a
map <ScrollWheelUp> <nop>
map <ScrollWheelDown> <nop>

Why does this method work and the others don't?

Last edited by cyberplunk (2025-09-30 02:08:00)

Offline

#2 2025-10-04 15:40:53

cyberplunk
Member
Registered: 2023-01-13
Posts: 28
LinuxFirefox 142.0

Re: [Solved] Disabling Scrolling in Vim

A response from BraveSearch AI, for anybody else with a similar question:

The behavior you're observing stems from how Vim interprets mouse events based on the terminal environment and the ttymouse setting.

When set mouse=a is active, Vim enables mouse reporting and interprets scroll wheel events (like <ScrollWheelUp> and <ScrollWheelDown>) as commands to scroll the window, which is the intended behavior for interactive navigation Mapping these events to <Nop> with nmap <ScrollWheelUp> <Nop> effectively disables the scroll wheel's function within Vim by intercepting the event before Vim processes it This works because the mapping is applied within Vim's own event handling system.

However, when set mouse= or set mouse-=a is used, mouse reporting is disabled. In this state, the terminal itself handles the scroll wheel events. The terminal sends cursor movement sequences (like CSI A for up, CSI B for down) directly to Vim, bypassing Vim's mouse event handling entirely Since these are standard cursor movement commands, they are not affected by Vim mappings like nmap <ScrollWheelUp> <Nop>, which only apply to Vim's internal mouse events. This is why the scroll wheel still causes the cursor to move even after the mapping.

Furthermore, the ttymouse= setting determines how Vim interprets mouse events from the terminal. If ttymouse=sgr is set (commonly needed for terminals like st), Vim expects mouse events in a different format If the terminal sends events in a format that Vim doesn't recognize or expects, it may fall back to interpreting them as cursor movements, which again bypasses Vim's mapping system Therefore, even with set mouse= or set mouse-=a, the underlying terminal's handling of the scroll wheel can still cause cursor movement if the ttymouse setting is not correctly configured for the terminal.

In summary, set mouse=a allows Vim to control the scroll wheel, making mappings effective. Disabling mouse reporting with set mouse= or set mouse-=a shifts control to the terminal, which sends raw cursor commands that are not intercepted by Vim's <Nop> mappings, thus the scrolling persists

Offline

Registered users online in this topic: 0, guests: 1
[Bot] ClaudeBot

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.009 seconds, 8 queries executed - Memory usage: 541.05 KiB (Peak: 541.67 KiB) ]