0

I use (neo)vim with mouse=a and scrolloff=5. Clicking on one of the top or bottom five lines with the mouse causes the screen to jump (so that the new cursor position is more centered), which distracts me. Is there any way to disable "so=5" for mouse-clicking only?

  • I'm not sure how that could work: scrolloff set a minimal number of lines below or above the cursor line. Disabling the option "only for mouse click" would mean that you don't have this minimal number of lines between the cursor line and the edge of the screen but how would vim know when to set this minimal number of lines again? – statox Apr 7 at 17:25
  • @statox preferably at the next vertical movement – 0x539 Apr 7 at 17:25
  • 1
    I'm pretty sure it's not possible to do what you want. You could try to use a mapping like nnoremap <leftmouse> :set scrolloff=0<CR><leftmouse> to disable scrolloff when you click and then remap the motion you want to reenable the option but that seems very impractical. – statox Apr 7 at 17:29
  • Do you need the answer to be a setting in vimrc or you need it to be a mouse-and-keyboard combination? – tivn 2 days ago
  • @tivn preferably a vimrc setting, but a mouse-and-keyboard combination would help too. – 0x539 2 days ago
0

Try the following: hold down shift key before you press mouse button.

  • Since I use neovim in the terminal this results in my terminal trying to select text. – 0x539 2 days ago
  • what’s the purpose you need to click there? – tivn 2 days ago
  • What’s the purpose of “Clicking on one of the top or bottom five lines” ? – tivn 2 days ago
  • usually the purpose is to move the cursor to that line. – 0x539 2 days ago
  • That’s of course would not possible :-) – tivn 2 days ago

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.