Skip to content

Instantly share code, notes, and snippets.

@ruslanosipov
Created August 8, 2014 18:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ruslanosipov/35379b6c753bf4f7e8a0 to your computer and use it in GitHub Desktop.
Save ruslanosipov/35379b6c753bf4f7e8a0 to your computer and use it in GitHub Desktop.
Configuration for tmux, good for use with Vim
# Use C-\ as a control sequence.
unbind-key C-b
set -g prefix 'C-\'
bind-key 'C-\' send-prefix
# Easy-to-remember split pane commands.
bind | split-window -h
bind - split-window -v
unbind '"'
unbind %
# Moving between panes with vim movement keys.
bind j select-pane -D
bind k select-pane -U
# Moving between windows with vim movement keys.
bind -r h select-window -t :-
bind -r l select-window -t :+
bind -r C-h select-window -t :-
bind -r C-l select-window -t :+
# Resize panes with vim movement keys.
bind -r H resize-pane -L 5
bind -r J resize-pane -D 5
bind -r K resize-pane -U 5
bind -r L resize-pane -R 5
# Smart pane switching with awareness of vim splits.
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"
# Don't swallow Escape key in Vim.
set -sg escape-time 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment