vim9script # Add and uncomment following lines to your .tmux.conf: # bind -n M-h if "[ $(tmux display -p '#{pane_current_command}') = vim ]" "send-keys M-h" "select-pane -L" # bind -n M-j if "[ $(tmux display -p '#{pane_current_command}') = vim ]" "send-keys M-j" "select-pane -D" # bind -n M-k if "[ $(tmux display -p '#{pane_current_command}') = vim ]" "send-keys M-k" "select-pane -U" # bind -n M-l if "[ $(tmux display -p '#{pane_current_command}') = vim ]" "send-keys M-l" "select-pane -R" if !has("gui_running") set =h set =j set =k set =l endif if empty($TMUX) noremap wincmd h noremap wincmd j noremap wincmd k noremap wincmd l inoremap wincmd h inoremap wincmd j inoremap wincmd k inoremap wincmd l tnoremap wincmd h tnoremap wincmd j tnoremap wincmd k tnoremap wincmd l finish endif var tmuxSocket = split($TMUX, ',')[0] def TmuxCommand(cmd: string): string return trim(system($"tmux -S {tmuxSocket} {cmd}")) enddef def TmuxVimNavigate(direction: string) var winnr = winnr() exe "wincmd" direction if winnr == winnr() && TmuxCommand("display-message -p '#{window_zoomed_flag}'") != "1" TmuxCommand($'select-pane -{tr(direction, "hjkl", "LDUR")}') endif enddef noremap TmuxVimNavigate("h") noremap TmuxVimNavigate("j") noremap TmuxVimNavigate("k") noremap TmuxVimNavigate("l") inoremap TmuxVimNavigate("h") inoremap TmuxVimNavigate("j") inoremap TmuxVimNavigate("k") inoremap TmuxVimNavigate("l") tnoremap TmuxVimNavigate("h") tnoremap TmuxVimNavigate("j") tnoremap TmuxVimNavigate("k") tnoremap TmuxVimNavigate("l")