When I use the mouse wheel to slide the document, the document does not move at first, but the mouse cursor moves. How can I set the mouse cursor not to move while the document moves, so I don’t have to always find where my mouse cursor is.

The following instructions are what I found, but they have no effect.

nnoremap <A-j> :m .+1<CR>==
nnoremap <A-k> :m .-2<CR>==
inoremap <A-j> <Esc>:m .+1<CR>==gi
inoremap <A-k> <Esc>:m .-2<CR>==gi
vnoremap <A-j> :m '>+1<CR>gv=gv
vnoremap <A-k> :m '<-2<CR>gv=gv

My Linux server version is:Linux version 4.15.0-122-generic (buildd@lcy01-amd64-010) (gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.12)) #124~16.04.1-Ubuntu SMP.

I am using a terminal to connect to the server. The terminal used is MobaXterm

  • Which operating system are you on? The behavior of the scroll wheel can depend on the O.S... Are you running a GUI version of Vim (such as GVim or MacVim) or are you running it on a terminal? If on a terminal, which terminal emulator are you using? – filbranden Nov 30 '20 at 2:13
  • 1
    Thank you for your comment, I added information – c yj Nov 30 '20 at 2:30
  • 3
    The commands you pasted are mappings for moving the current line or visual selection up and down within the document (i.e. editing the text), so they’re definitely not what you’re looking for. – Rich Nov 30 '20 at 9:34
  • Do you know what I should do? Thank you. – c yj Nov 30 '20 at 11:22
  • 1
    do you have any mouse config in your vimrc? like set mouse=a? – alec Nov 30 '20 at 22:35

Like Rich mentioned, the vim config you posted is unrelated to the mouse.

You might try adding:

if has('mouse')
  set mouse=a

...to your .vimrc.

In regards to:

so I don’t have to always find where my mouse cursor is

set cursorline is a handy option for making the position of the cursor easily detectable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.