Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to select text with mouse scrolling in vim?

Tags:

vim

Sometimes I want to copy some content on remote host in vim, which will last for more than 1 page. But when clicked by left-click of mouse, and scrolling down, I find I was stuck at the first page.

I know I can use scp or first cat file then select.

But is there a way to enable mouse scrolling to do such a selection in vim?

like image 678
Zen Avatar asked Dec 06 '25 03:12

Zen


1 Answers

First, I'd avoid the problem entirely. Start a selection using v before you start scrolling. Then the start of the selection stays put and only the end of the selection moves as you scroll. Then make sure to Shift+click instead of just clicking to set the end position.

But if you really want to be able to scroll with the mouse while holding the button to select text, check your 'mouse' option to make sure it contains "a" or "v". It sounds like you may be using a "modeless selection" (:help gui-mouse-modeless) by mistake. A modeless selection only allows you to select text currently on the screen (it does not scroll), but it also lets you select non-text like line numbers.

Also check that you don't have any mappings defined for the scroll events documented in :help scroll-mouse-wheel. For me this feature "just works" in Windows gvim, so I'm not sure what would cause it to not work for you. But I had to try it out so see, since I almost never do that anyway.

like image 71
Ben Avatar answered Dec 08 '25 20:12

Ben



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!