Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use mouse scroll wheel in Vim

My .vimrc has the following lines

set mouse=a map <ScrollWheelUp> <C-Y> map <ScrollWheelDown> <C-E> 

But when I scroll up using the mouse wheel, I'd get the text above Vim. For example, I'd get my terminal session text if I'd just started Vim. I'm initially experimenting with the mouse scroll wheel on help files, then move on to other files, hence the a option.

What else do I need to set? I'm using Snow Leopard and Vim 7.3 inside a Terminal.

Here, I just did a wheel up. See the Terminal session at the top. enter image description here

like image 419
Kit Avatar asked Aug 29 '11 00:08

Kit


People also ask

How do I scroll in Vim?

You can make Vim scroll the text using the shifted up/down arrows by mapping Shift-Up to Ctrl-Y and Shift-Down to Ctrl-E. Shift-Down will then scroll down (like moving a scroll-bar down, or like moving a cursor at the bottom of a window down), and Shift-Up will then scroll up (like moving a scroll-bar up, etc).

How do I select and scroll in Vim?

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.

How do I scroll faster in Vim?

Of course you can advance by full screens using Ctrl+F and Ctrl+B . You can directly go to a particular line by typing the line number in normal mode and pressing capital G .

How do I change my mouse scroll in Ubuntu?

Install Imwheel Manually Now, paste the script into Text Editor and name the file mousewheel.sh. Doing so will open the dialog box to set mouse scroll speed on your terminal screen, with the help of which you can change your mouse scroll speed in Ubuntu.


2 Answers

Using vim in iTerm 2 in OS X, you can :set mouse=a to enable scrolling with the scroll wheel, as well as selecting to enter Visual mode, etc.

like image 103
taylor Avatar answered Sep 20 '22 15:09

taylor


If you use iTerm, you can simply execute the following command:

defaults write com.googlecode.iterm2 AlternateMouseScroll -bool true

This will enable mouse scrolling without having to add anything in your .vimrc.

like image 36
BiBi Avatar answered Sep 20 '22 15:09

BiBi