1" tmux.vim - Set xterm input codes passed by tmux
2" Author:        Mark Oteiza
3" License:       Public domain
4" Description:   Simple plugin that assigns some xterm(1)-style keys to escape
5" sequences passed by tmux when "xterm-keys" is set to "on".  Inspired by an
6" example given by Chris Johnsen at:
7"     https://stackoverflow.com/a/15471820
8"
9" Documentation: help:xterm-modifier-keys man:tmux(1)
10
11if exists("g:loaded_tmux") || &cp
12  finish
13endif
14let g:loaded_tmux = 1
15
16function! s:SetXtermCapabilities()
17  set ttymouse=sgr
18
19  execute "set <xUp>=\e[1;*A"
20  execute "set <xDown>=\e[1;*B"
21  execute "set <xRight>=\e[1;*C"
22  execute "set <xLeft>=\e[1;*D"
23
24  execute "set <xHome>=\e[1;*H"
25  execute "set <xEnd>=\e[1;*F"
26
27  execute "set <Insert>=\e[2;*~"
28  execute "set <Delete>=\e[3;*~"
29  execute "set <PageUp>=\e[5;*~"
30  execute "set <PageDown>=\e[6;*~"
31
32  execute "set <xF1>=\e[1;*P"
33  execute "set <xF2>=\e[1;*Q"
34  execute "set <xF3>=\e[1;*R"
35  execute "set <xF4>=\e[1;*S"
36
37  execute "set <F5>=\e[15;*~"
38  execute "set <F6>=\e[17;*~"
39  execute "set <F7>=\e[18;*~"
40  execute "set <F8>=\e[19;*~"
41  execute "set <F9>=\e[20;*~"
42  execute "set <F10>=\e[21;*~"
43  execute "set <F11>=\e[23;*~"
44  execute "set <F12>=\e[24;*~"
45
46  execute "set t_kP=^[[5;*~"
47  execute "set t_kN=^[[6;*~"
48endfunction
49
50if exists('$TMUX')
51  call s:SetXtermCapabilities()
52