tmux: enable mouse scrolling in vim instead of history buffer

20

12

I have just started using tmux 1.8 recently, after working with screen for a while. After reading things here and there on the internet, I came up with following ~/.tmux.conf However when I open vim and try to scroll with mouse tmux scrolls through its scroll buffer instead of sending the scroll command to vim. Is there a workaround? Following is my config:

set-option -g default-shell /bin/bash


set -g status-utf8 on
set -g status-keys vi
set -g status-interval 1

set -g prefix `
bind `     send-key `

bind-key -n F9  resize-pane -Z
bind-key -n F11 prev
bind-key -n F12 next-window

bind-key | split-window -h
bind-key - split-window -v
set -s escape-time 0
set -g history-limit 100000

set -g mode-mouse on
set -g mouse-resize-pane on
set -g mouse-select-pane on
set -g mouse-select-window on
set-option -g mouse-utf8 on

set -g status-bg '#666666'
set -g status-fg '#aaaaaa'
set -g status-left ''
set -g status-right ''

set-option -sg escape-time 1

UPDATE:

Found the answer. I had to set my term to xterm, it was getting value of screen. When I do following:

export TERM=xterm

and inside vim:

set mouse=a

I had no issues in scroll inside the file opened in vim under tmux. If I have to scroll to history buffer I do (prefix) [ and then use mouse. It works like a charm!

thequark

Posted 2013-06-20T16:41:53.387

Reputation: 337

Does vim have mouse enabled? I have zero issues with vim inside of tmux on three different OS's (with tmux and vim mouse modes on at the same time). – demure – 2013-06-21T02:59:34.063

After I do mouse=a in vim and open a new file in vim inside tmux, vim doesn't show anything. The display gets stuck at the command line where I had executed vim. Either I have to kill it or split the window and 'unsplit' it back.

I tried above settings with and without set mouse=a inside vim. None of them work. – thequark – 2013-06-21T06:28:52.477

Answers

30

Adding following to your .vimrc does it.

set mouse=a

This enables mouse in all modes, hence a for all. See vim manpages and http://vim.wikia.com/wiki/Using_the_mouse_for_Vim_in_an_xterm.

Victor Häggqvist

Posted 2013-06-20T16:41:53.387

Reputation: 431