From c47ffb218e6d44effc3ddef286403d2613f1c766 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 18 Nov 2015 00:58:42 -0500 Subject: [PATCH] Fix vim<->tmux pane-switching bindings --- tmux.conf | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tmux.conf b/tmux.conf index 582ff6b6..84d613eb 100644 --- a/tmux.conf +++ b/tmux.conf @@ -47,12 +47,14 @@ unbind '"' bind s split-window -v bind v split-window -h -# Navigate between panes -bind -n C-h run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)g?(view|vim?)(diff)?$' && tmux send-keys C-h) || tmux select-pane -L" -bind -n C-j run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)g?(view|vim?)(diff)?$' && tmux send-keys C-j) || tmux select-pane -D" -bind -n C-k run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)g?(view|vim?)(diff)?$' && tmux send-keys C-k) || tmux select-pane -U" -bind -n C-l run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)g?(view|vim?)(diff)?$' && tmux send-keys C-l) || tmux select-pane -R" -bind -n C-\ run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)g?(view|vim?)(diff)?$' && tmux send-keys 'C-\\') || tmux select-pane -l" +# Smart pane switching with awareness of vim splits +# See: https://github.com/christoomey/vim-tmux-navigator +is_vim='echo "#{pane_current_command}" | grep -iqE "(^|\/)g?(view|n?vim?x?)(diff)?$"' +bind -n C-h if-shell "$is_vim" "send-keys C-h" "select-pane -L" +bind -n C-j if-shell "$is_vim" "send-keys C-j" "select-pane -D" +bind -n C-k if-shell "$is_vim" "send-keys C-k" "select-pane -U" +bind -n C-l if-shell "$is_vim" "send-keys C-l" "select-pane -R" +bind -n C-\ if-shell "$is_vim" "send-keys C-\\" "select-pane -l" bind H resize-pane -L 5 bind J resize-pane -D 5