Enable Vim mode in tmux by adding set-window-option -g mode-keys vi
to your ~/.tmux.conf
file. This allows you to use vi-style keybindings in copy mode for navigation and text selection.
set-window-option -g mode-keys vi
tmux's copy mode supports two sets of keybindings: Emacs-style (default) and Vi-style. By enabling Vi mode, you can use familiar Vim navigation and selection commands in tmux, which is especially useful for Vim users.
Add the following line to your ~/.tmux.conf
file:
# Enable Vi mode set-window-option -g mode-keys vi # Or the shorter version setw -g mode-keys vi
After enabling Vi mode and entering copy mode (Ctrl+b [), you can use these key bindings:
Enhance Vi mode by adding these keybindings to your ~/.tmux.conf
:
# Setup 'v' to begin selection, just like Vim bind-key -T copy-mode-vi v send-keys -X begin-selection # Setup 'y' to yank (copy), just like Vim bind-key -T copy-mode-vi y send-keys -X copy-selection-and-cancel # Update the default binding of 'Enter' to use copy-selection-and-cancel unbind-key -T copy-mode-vi Enter bind-key -T copy-mode-vi Enter send-keys -X copy-selection-and-cancel
If you use Neovim or Vim inside tmux, add this to your ~/.tmux.conf
to reduce escape key delay:
# Reduce delay when pressing Escape in Vim set -sg escape-time 10