Search code examples
vimtmux

"set-window-option -g mode-keys vi" doesn't work in .tmux.conf


I've been able to turn-on the vi-mode inside tmux successfully by pressing C-a : (I've changed default prefix) and then typing set-window-option mode-keys vi. However, I can't make it stick by adding into ~/.tmux.conf. Here is my config:

# Change default prefix key to C-a
unbind-key C-b
set -g prefix 'C-a'
bind-key 'C-a' send-prefix

# Configure Vim mode for navigating text and selection
set-window-option -g mode-keys vi
bind-key -t vi-copy 'v' begin-selection
bind-key -t vi-copy 'y' copy-selection

# Allow navigating panes with vi-like commands.
bind k selectp -U
bind j selectp -D
bind h selectp -L
bind l selectp -R

Notably, navigating panes using kjhl keys also doesn't work. Perhaps this is because tmux fails to execute set-window-option earlier in the script. What's wrong here?


Solution

  • Try using setw -g mode-keys vi