94

I've been googling around trying to figure out if it's possible to use my mouse wheel to scroll while inside Vim in Mac's Terminal, with no luck. It seems as if only X11 or iTerm support this.

Before I give up, I thought I'd try the geniuses here to see if anyone knows a way to do this. So, does anyone know if I can set that up?

Or should I seriously consider using a different terminal application?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
hora
  • 3,661
  • 5
  • 25
  • 26
  • Is this something you can do in other platforms or terminal editors? If there was an X-based VI implementation, I guess it could support that, but wouldn't you rather have support for the scroll mouse to control the scrollback buffer? – benc Nov 13 '09 at 09:16
  • In Ubuntu's terminal you can scroll, that's why I was asking, I wanted to see if I could have the same functionality on my Mac. – hora Nov 13 '09 at 18:13
  • 1
    @hora - you can, just use iterm. You also get 256 colors, sensible copy and paste etc. – robince Nov 22 '09 at 14:11

11 Answers11

106

And if you're using iTerm, add this to your vimrc

:set mouse=a
Shane Reustle
  • 8,633
  • 8
  • 40
  • 51
69

http://bitheap.org/mouseterm/

Use MouseTerm (and do make sure to install SIMBL first!) and scrolling will work like a charm, even remote, using Mac Terminal.

You need to fully quit the Terminal application (Command+Q) and then launch it again after installing MouseTerm.

SheetJS
  • 22,470
  • 12
  • 65
  • 75
Jonatan Littke
  • 5,583
  • 3
  • 38
  • 40
  • 2
    Wow, that's exactly what I was looking for. In the meanwhile I've gotten used to NOT using my mouse, but this is still useful. – hora May 03 '10 at 18:29
  • 8
    For vim nuts adding a `set mouse=a` in your .vimrc works like a charm with MouseTerm – Panagiotis Moustafellos Mar 28 '13 at 21:37
  • 5
    If you're looking for SIMBL and you're trying to get it to work on Lion, try EasySIMBL: https://github.com/norio-nomura/EasySIMBL/downloads – Zachary Murray Jul 25 '13 at 22:55
  • 2
    can confirm that EasySIMBL + MouseTerm also works on Mavericks – jcr Jan 17 '14 at 11:51
  • 2
    Latest EasySIMBL releases are now here (currently 1.6): https://github.com/norio-nomura/EasySIMBL/releases – Nathaniel Heinrichs Jan 28 '14 at 13:28
  • 1
    `:set mouse=a` inside of a session, or `set mouse=a` in your .vimrc works like a charm and seems much simpler, @ShaneReustle 's answer is probably the (more) correct one :/ – sammms May 25 '17 at 17:26
42

This is an old question, but a top hit on google, so I feel compelled to provide an updated answer.

Running OSX El Capitan 10.11, vim mouse and trackpad scrolling just worked(TM) for me in Terminal.app by default. However occasionally the mouse/trackpad input stopped manipulating the vim buffer, and started scrolling the terminal buffer. The answer was Command+R or Menu View --> Allow Mouse Reporting. Turning that on allowed the mouse/trackpad scroll operations to move the cursor in vim.

Steve Walsh
  • 127
  • 1
  • 7
mmacvicar
  • 761
  • 6
  • 9
9
  • Termanal Menu > View > Allow Mouse Reporting
  • Terminal Menu > Preferences > Keyboard > Scroll alternate screen
Afagh
  • 103
  • 1
  • 4
6

If the mouse functionalities still do not work properly take a look at my answer in this post How to let vim behave on Mac OS X as on Ubuntu?, just add to your .vimrc

set ttymouse=xterm2
Community
  • 1
  • 1
apochev
  • 301
  • 2
  • 8
4

You can read this article, but I'm pretty sure since the default terminal in Mac OS X has a built-in scrollbar, the mousewheel commands automatically go to it. You could definitely use gVim as suggested in the previous answer. I find that I don't generally want to use the mouse in Vim though as it takes my hands off the keyboard.

I just use 50j to go down and 50k to go up. Not exactly scrolling, but it works pretty well.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Topher Fangio
  • 20,372
  • 15
  • 61
  • 94
  • Thanks, that's not exactly scrolling but I think that's better since my hands are always on the keyboard. – hora Nov 13 '09 at 06:19
  • @hora - Yeah, scrolling would definitely be nice, but unfortunately, I don't think it's doable. – Topher Fangio Nov 13 '09 at 15:12
  • 14
    Or use CTRL+f and CTRL+b to move forward and back by one screen at a time. Or CTRL+d and CTRL+u to move up and down by half a screen. – Dan Dyer Nov 15 '09 at 10:59
  • It's not just scrolling - you also get the ability to mark visual selections with the mouse, move window boundaries etc. It basically makes a graphical program redundant and is great for when you're working on a remote machine. – robince Nov 22 '09 at 14:12
  • @thrope - Very true, I use that quite often actually. `v` for visual mode and then select the text I want. However, I usually want an entire line or set of lines, so, to avoid newline pasting problems, I generally just count the lines and hit `dd` to delete them. A bit slower sometimes, but it's what I've gotten used to. – Topher Fangio Nov 23 '09 at 15:02
2

Make sure the terminal is xterm & not ansi in Terminal Menu > Preferences > Profiles > Advanced. I accidentally broke scrolling by changing the term type in a naive effort to get coloring to work over ssh.

dayne
  • 7,504
  • 6
  • 38
  • 56
1

Use gVim, which gives you a text editing environment in a window you can scroll. Terminal is not involved when using gVim.

Greg Hewgill
  • 951,095
  • 183
  • 1,149
  • 1,285
  • 2
    Not really relevant - he might be accessing vim on another machine (through ssh) - In any case, on a mac, macvim is the preferred graphcial version http://code.google.com/p/macvim/ – robince Nov 22 '09 at 14:10
1

I'm using xterm in X11 (XQuartz 2.3.4) and vim works very fine with mouse and also suport 256 colors.

Here is the ~/.Xresources I use to make my xterm nicer in X11:

XTerm*faceName: Lucida Sans Typewriter Regular
XTerm*faceSize: 9
XTerm*utf8: 1

xterm*saveLines: 1000
xterm*jumpScroll: true
!xterm*awaitInput: true
!xterm*multiScroll: true

XTerm*scrollBar: false
xterm*scrollbar*thickness: 16
xterm*rightScrollBar: true

XTerm*foreground: white
XTerm*background: grey10
!XTerm*background: black
XTerm*cursorColor: yellow

xterm*visualBell: false

xterm*loginShell: true

Little tips, to remove the bell sound in X11's xterm type this command:

xset b 0
XPac27
  • 301
  • 2
  • 8
  • I've tried xterm, not a big fan though I dunno why, there's something about it that puts me off. Maybe I'll give it another shot. – hora Nov 22 '09 at 22:13
  • The only thing that changes is for copying and pasting. Paste done by mouse's middle click (or alt + click) and copy is done just by selecting some text. Of course in vim you'll have to disable the mouse to be able to copy something outside X11 or paste something from outside X11 or vim while override X11's mouse behavior. – XPac27 Nov 23 '09 at 13:33
1

I would recommend using iTerm - it has so many advantages over Terminal eg Mouse support, 256 colors, sensible copy and paste (auto-copy, word/url selection with double click, middle click paste)...

robince
  • 10,826
  • 3
  • 35
  • 48
  • Are there built in colour schemes in iTerm? How do I change the colours, can't seem to figure it out... The 'show session info' dialogue doesn't seem to let me save different profiles. – hora Nov 22 '09 at 22:16
  • Yeah the configuration setup is a bit funny... Go to Bookmarks -> Manage Profiles -> Display Profiles and you can setup colors. Then you go to Bookmarks -> Manage Bookmarks and setup default or whichever one you want to use the display profile you want. – robince Nov 22 '09 at 22:20
  • I can't even Option + Left Arrow to go back a word at a time in iTerm. Are you kidding me right now? – IIllIIll Nov 29 '15 at 03:34
-1

When using iTerm create a .vimrc file (if not already there) in your home folder and add the line:

:set mouse=a

Scrolling down in vim to view a file works after this.

Shashank
  • 1
  • 2