To move to the next pane in tmux, press Ctrl+b o. This cycles through all panes in the current window in order. You can also use Ctrl+b arrow keys to move in specific directions.
Ctrl+b o
Navigating between panes is a core part of the tmux workflow. There are several methods to move between panes, each suitable for different situations.
# Move to the next pane in sequence Ctrl+b o # Move to the previous pane in sequence Ctrl+b ;
This method cycles through panes in the order they were created. It's useful when you have multiple panes and want to visit each one in turn.
# Move to the pane above Ctrl+b Up # Move to the pane below Ctrl+b Down # Move to the pane on the left Ctrl+b Left # Move to the pane on the right Ctrl+b Right
Directional navigation is intuitive when you have a visual layout of panes and want to move to a specific adjacent pane.
Each pane has a number that appears temporarily when you press:
# Display pane numbers Ctrl+b q # Then quickly press the number key to switch to that pane # For example, press '0' to jump to pane 0
This method is especially useful when you have many panes and want to jump directly to a specific one.
# Using tmux command prompt Ctrl+b :select-pane -t 2 # Select pane number 2 # Directional selection with the command Ctrl+b :select-pane -U # Up Ctrl+b :select-pane -D # Down Ctrl+b :select-pane -L # Left Ctrl+b :select-pane -R # Right
The command-based approach is useful for scripting or when creating custom key bindings for more complex navigation.
Add these to your ~/.tmux.conf
file:
# Use Alt+arrow keys to switch panes without prefix bind -n M-Left select-pane -L bind -n M-Right select-pane -R bind -n M-Up select-pane -U bind -n M-Down select-pane -D # Use Vim-like keys for navigation bind h select-pane -L bind j select-pane -D bind k select-pane -U bind l select-pane -R
If you prefer using a mouse, you can enable mouse mode in tmux:
# Enable mouse support set -g mouse on
With mouse mode enabled, you can simply click on a pane to select it.
Create a visual indicator for the active pane by customizing its border in your ~/.tmux.conf
:
# Set active pane border style set -g pane-active-border-style "fg=green,bg=default" set -g pane-border-style "fg=brightblack,bg=default"
This makes it easier to identify which pane is currently active, especially in layouts with many panes.
For Vim users, this configuration seamlessly integrates navigation between tmux panes and Vim splits:
# Smart pane switching with awareness of Vim splits is_vim="ps -o state= -o comm= -t '#{pane_tty}' \ | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?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'
This allows you to use the same keys (Ctrl+h/j/k/l) to navigate both tmux panes and Vim splits.