Kit
Kit

Reputation: 31513

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

Upvotes: 59

Views: 84836

Answers (6)

BiBi
BiBi

Reputation: 7908

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.

Upvotes: 28

Jaeeun Ham
Jaeeun Ham

Reputation: 1

Mouse wheel action works when your TERM is set to xterm not to linux. So, please set "setenv TERM xterm" in the .cshrc or .bashrc, then it will work.

Upvotes: 0

taylor
taylor

Reputation: 1628

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.

Upvotes: 116

ManuelSchneid3r
ManuelSchneid3r

Reputation: 16091

Just an option. I missed a lot of functionality in OSX, which I was totally used to from linux. The best setup that comes close to urxvt + vim is to use iTerm2 + MacVim.

Just a few things is missed and got back this way:

  • Pos1+End,
  • PgUp+PgDown,
  • Mouse support,
  • as-expected-scolling,
  • cool arrangements and the intuitive keyboard movement I horribly missed from the gorgeous i3-wm,
  • nerdy dimm effects and
  • sloppy focus (focus follows mouse).

Unfortunately the most outstanding feature "middlemouse-clipboard" from xorg is not implemented in any term I know. Well as said its an xorg feature, and will probably never be implemented.

If your on the way to make the terminal useful in OS X don't forget the masterpiece homebrew.

Upvotes: 0

asmeurer
asmeurer

Reputation: 91480

You could try using https://github.com/brodie/mouseterm, which adds mouse reporting support to Terminal.

Upvotes: 4

satran
satran

Reputation: 1232

I had the same problem using Mac's Terminal. I think it is an issue with it. Once I upgraded to Lion I don't have the problem of scrolling in vim. Please consider using iTerm2. It will solve the problem of scrolling and gives you the 256 term colors.

Upvotes: 2

Related Questions