tmux-vim integration to transparently switch between tmux panes and vim split windows
# Smart pane switching with awareness of vim splits bind -n C-k run-shell 'tmux-vim-select-pane -U' bind -n C-j run-shell 'tmux-vim-select-pane -D' bind -n C-h run-shell 'tmux-vim-select-pane -L' bind -n C-l run-shell 'tmux-vim-select-pane -R' bind -n "C-\\" run-shell 'tmux-vim-select-pane -l' # Bring back clear screen under tmux prefix bind C-l send-keys 'C-l'
I use tmux splits (panes). Inside one of these panes there's a Vim process, and it has its own splits (windows).
In Vim I have key bindings
C-h/j/k/l set to switch windows in the given direction. (Vim default mappings for windows switching are the same, but prefixed with
C-W.) I'd like to use the same keystrokes for switching tmux panes.
An extra goal that I've solved with a dirty hack is to toggle between last active panes with
Here's how it should work:
C-h) or down (
C-j) direction should switch windows inside vim.
C-l) or down (
C-j) should select the next tmux pane in that direction.
The solution has 3 parts:
~/.tmux.conf, I bind the keys I want to execute a custom
tmux-vim-select-panechecks if the foreground process in the current tmux pane is Vim, then forwards the original keystroke to the vim process. Otherwise it simply switches tmux panes.
tmux -V that you have v1.8
get the vim-tmux-navigator plugin
~/.tmux.conf config &
curl -fsSL https://gist.github.com/mislav/5189704/raw/install.sh | bash -e