11
votes

I'm using bash on ubuntu on windows 10 and would like to enable scrolling using the mouse wheel in vi or vim. I've tried entering the following command in vim and added it to the .vimrc file and /usr/share/vim/vim74/debian.vim

set mouse=a

However I still can't scroll with the mouse.

4
"I'm using bash on ubuntu on windows 10" -> Ehm, what? Also, your question is confusing, first you say you want to "enable scrolling" and then you state twice that this works? ("I still can scroll" and "the mouse wheel does work in the terminal")? What exactly isn't working where?Martin Tournoij
Facing the same issue here. Lol @ the close votes.. for everyone living under a rock: Bash on Ubuntu on Windows.Salman von Abbas
I think one possible solution may be to install an x server. Ive seen some articles mention Xming X server for windows but I have hesitated to delve into this possibility. Id like to know if anyone tries it though! For now I'm just using notepad++ to edit my code and using the terminal to browse and compile like I normally would.nak3c

4 Answers

9
votes

I added this to my /etc/vim/vimrc.local, and it worked:

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

You have done, properly, all you can in vim and the problem is with your terminal emulator.

Mouse wheel scrolling through the scrollback buffer of a terminal emulator is a function of the terminal emulator which is consuming the mouse events. You are wanting to send these events to the application (vim) hooked to the terminal.

Most terminal emulators have a way to enable the passthrough of mouse events when in "Application Key Mode" or "Alternate Screen". Most also support using a modifier key (like holding ALT) that will passthrough the mouse events as you wish.

3
votes

Quick and simple answer:

If you use mintty/wsltty it works just fine!

0
votes

Your version of Vim may not have been compiled with mouse support. See if you can get gvim. It contains a graphical version of Vim. Depending on your distribution it may also contain the terminal vim with almost all features enabled, including mouse support.

To check for mouse support in Vim, enter :version and check whether +mouse is in the list of features.