Jay Taylor's notes

back to listing index

Enable mouse for scrolling only in Vim in iTerm (MacOSX)

[web search]
Original source (superuser.com)
Tags: iTerm iTerm2 vim mouse superuser.com
Clipped on: 2016-03-02

I'd like to use the mouse in Vim only for scrolling (not to enable other Vim modes or otherwise interact with Vim). Using :set mouse=a seems to be an all or nothing operation, can this be altered? Alternatively can iTerm be made to only pass through scroll events and never click/drag events?

Long Explanation: I use Vim in iTerm a lot and don't use the mouse. However, inertia scrolling with a trackpad is really nice and a great way to peruse large files. I can :set mouse=a and use the trackpad to scroll and it's great. Now when I click however vim enters visual mode and iTerm will not copy selected text. I would like to retain iTerms ability to select and copy text.

I have thought about setting up Vim so that copying in vim will copy in Mac OS X (using pbcopy, I need to do this anyway). This will do the trick when editing local files, but most of the time I'm ssh'd somewhere and editing remote files.

asked Jan 27 '11 at 5:34
Image (Asset 3/19) alt=
Jonah Braun
7171912
up vote 23 down vote accepted

You could use

:set mouse=nicr

It works only with mouse scroll as I've tested.

answered Dec 15 '11 at 18:45
Image (Asset 4/19) alt=
netoarmando
34624
1 upvote
  flag
Not quite what I need as while it will scroll in vim, iTerm won't let me select text. I've :set mouse=i so that scroll works in insert mode and iTerm select in normal mode. Close enough, so I'm marking answered. Thanks for the idea! – Jonah Braun Dec 15 '11 at 21:30
2 upvote
  flag
That looks like "set the mouse to be nicer" to me. – Kazark Aug 30 '12 at 17:07
4 upvote
  flag
@JonahBraun, iTerm will mouse select with :set mouse=nicr if you hold down option while making the selection. See stackoverflow.com/questions/4608161/… – John Whitley Mar 22 '13 at 23:58

If you set mouse=a, you can still use Option-click to make iTerm do selection. Not ideal, but it's the best option I've found.

answered Dec 6 '12 at 20:09
Image (Asset 5/19) alt=
   upvote
  flag
this is the real workable answer. – Zen Feb 15 '15 at 7:46

I'm not sure about iTerm but this is achievable with Terminal.app.

  • Scrolling in Terminal.app:

http://ayaz.wordpress.com/2010/10/19/using-mouse-inside-vim-on-terminal-app/ (install SIMBL and MouseTerm)

  • Scrolling only:

    1. Go to terminal;
    2. Preference;
    3. 'Settings' Icon;
    4. 'Keyboard' Tab
    5. 'Mouse...' button;
    6. There under 'Send mouse events for:" uncheck "Left click", "Middle click", "Right click".

Done.

answered May 3 '11 at 1:34
Image (Asset 7/19) alt=
LiL
111

Even better than the accepted answer:

set mouse=a

This allows scrolling and then highlighting gives you a visual block.

answered May 24 '12 at 22:00
Image (Asset 9/19) alt=
ibash
111
1 upvote
  flag
This enables things other than scrolling. – Kazark Aug 30 '12 at 17:10
1 upvote
  flag
Moreover, that is already mentioned in the question. – Kazark Aug 30 '12 at 17:15

Your Answer

asked

5 years ago

viewed

10712 times

active

3 years ago

Hot Network Questions

Technology Life / Arts Culture / Recreation Science Other
  1. Stack Overflow
  2. Server Fault
  3. Super User
  4. Web Applications
  5. Ask Ubuntu
  6. Webmasters
  7. Game Development
  8. TeX - LaTeX
  1. Programmers
  2. Unix & Linux
  3. Ask Different (Apple)
  4. WordPress Development
  5. Geographic Information Systems
  6. Electrical Engineering
  7. Android Enthusiasts
  8. Information Security
  1. Database Administrators
  2. Drupal Answers
  3. SharePoint
  4. User Experience
  5. Mathematica
  6. Salesforce
  7. ExpressionEngine® Answers
  8. more (13)
  1. Photography
  2. Science Fiction & Fantasy
  3. Graphic Design
  4. Movies & TV
  5. Seasoned Advice (cooking)
  6. Home Improvement
  7. Personal Finance & Money
  8. Academia
  9. more (9)
  1. English Language & Usage
  2. Skeptics
  3. Mi Yodeya (Judaism)
  4. Travel
  5. Christianity
  6. Arqade (gaming)
  7. Bicycles
  8. Role-playing Games
  9. more (21)
  1. Mathematics
  2. Cross Validated (stats)
  3. Theoretical Computer Science
  4. Physics
  5. MathOverflow
  6. Chemistry
  7. Biology
  8. more (5)
  1. Stack Apps
  2. Meta Stack Exchange
  3. Area 51
  4. Stack Overflow Careers
site design / logo © 2016 Stack Exchange Inc; user contributions licensed under cc by-sa 3.0 with attribution required
rev 2016.3.2.3314