20

My vim can't scroll in iTerm2 even set mouse=a has added in .vimrc file.

Within tmux, however, vim's scroll function works correctly.

What's wrong with my vim?

pfnuesel
  • 14,093
  • 14
  • 58
  • 71
Douglas Su
  • 3,214
  • 7
  • 29
  • 58

2 Answers2

43

Recent versions of vim support the "SGR" protocol, you can add code bellow to your .vimrc:

set mouse=a
if has("mouse_sgr")
    set ttymouse=sgr
else
    set ttymouse=xterm2
end
Valery Viktorovsky
  • 6,487
  • 3
  • 39
  • 47
  • unfortunately this make text selection with mouse different (highlights with solid dark color).. any way to fix that? – Sush Aug 23 '22 at 15:37
24

I had the same issue, and Valery's answer did not work for me. What did work is checking the "Enable mouse reporting" box under Profiles > Terminal in the iTerm preferences.

Simon Alford
  • 2,405
  • 1
  • 12
  • 10