Enable mouse for scrolling only in Vim in iTerm (MacOSX)
Solution 1
You could use
:set mouse=nicr
It works only with mouse scroll as I've tested.
Solution 2
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.
Solution 3
For Iterm2
Preference -> Advanced -> Mouse Tab, switch:
Scroll wheel sends arrow keys when in alternate screen mode
to:
Yes
Solution 4
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:
- Go to terminal;
- Preference;
- 'Settings' Icon;
- 'Keyboard' Tab
- 'Mouse...' button;
- There under 'Send mouse events for:" uncheck "Left click", "Middle click", "Right click".
Done.
Related videos on Youtube
Jonah Braun
Updated on September 17, 2022Comments
-
Jonah Braun over 1 year
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. -
Jonah Braun over 12 yearsNot 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! -
Kazark over 11 yearsThat looks like "set the mouse to be nicer" to me.
-
Kazark over 11 yearsThis enables things other than scrolling.
-
Kazark over 11 yearsMoreover, that is already mentioned in the question.
-
John Whitley about 11 years@JonahBraun, iTerm will mouse select with
:set mouse=nicr
if you hold down option while making the selection. See stackoverflow.com/questions/4608161/… -
Zen about 9 yearsthis is the real workable answer.
-
Naguib Ihab almost 5 yearsWhere do you write
:set mouse=nicr
? -
sshine about 3 yearsYou can either write that every single time you start Vim, or you could write that in the file
~/.vimrc
, but consider also:set mouse=a
, as @MikeMorearty suggests below. This makes selection of text possible, too. (It goes into visual mode, which some may not like.) -
sshine about 3 yearsIt certainly is.
-
cmrust about 3 yearsEnter vim > mouse wheel scrolls within vim only. Perfect, thanks!
-
miguno about 2 yearsIn my case you must set this iTerm config AND hold down
Option
when scrolling with the trackpad/the mouse wheel.