How to exit copy mode in tmux?

Quick Answer

To exit copy mode in tmux, press q or Escape. If you're using Vim keybindings, you can also press Enter to exit copy mode after making a selection. Another method is to press Ctrl+c, which cancels the current operation and exits copy mode regardless of keybinding mode.

# Exit copy mode (Emacs key bindings)
q
Escape

# Exit copy mode (Vim key bindings)
q
Escape
Enter (after selection)

Detailed Explanation

Copy mode in tmux allows you to navigate the pane buffer, select text, and copy content for pasting. Knowing how to exit copy mode is essential for efficient tmux usage, especially as different key binding modes offer different exit methods.

Default Methods to Exit Copy Mode

Regardless of your key binding mode, these methods should work to exit copy mode:

  • Press q to quit copy mode without copying
  • Press Escape to cancel and exit
  • Press Ctrl+c to force exit from any mode

Exiting Based on Key Binding Mode

tmux supports two main key binding modes for copy mode: Emacs (default) and Vim. The exit methods can vary slightly:

Emacs mode (default):

  • q - Exit copy mode
  • Escape - Cancel the current selection and exit
  • Ctrl+g - Cancel and exit (Emacs-style)
  • Ctrl+Space followed by Alt+w - Copy selection and exit

Vim mode:

  • q - Exit copy mode
  • Escape - Cancel the current selection and exit
  • Enter - After making a selection, copies the text and exits copy mode
  • v then select text then y - Make selection, yank (copy) and exit

Checking Your Key Binding Mode

To check which key binding mode you're using for copy mode:

# In tmux command mode (Ctrl+b :)
show-options -g mode-keys

This will show either "emacs" (default) or "vi" depending on your configuration.

Changing Key Binding Mode

If you prefer Vim-style key bindings for copy mode, add this to your ~/.tmux.conf:

# Use vi keys in copy mode
setw -g mode-keys vi

For Emacs-style key bindings (default):

# Use emacs keys in copy mode
setw -g mode-keys emacs

Common Issues When Exiting Copy Mode

If you're having trouble exiting copy mode:

  • "Stuck" in copy mode - Try pressing Ctrl+c multiple times
  • Exit keys not working - Check if you're using the right keys for your mode-keys setting
  • Custom key bindings - Your tmux configuration might have redefined the default keys
  • Terminal issues - Some terminal emulators might intercept certain keys

Pro Tip

Create a custom binding for quickly exiting copy mode and returning to the command prompt:

# Add to ~/.tmux.conf
bind-key -T copy-mode-vi 'C-x' send-keys -X cancel
bind-key -T copy-mode 'C-x' send-keys -X cancel

With this configuration, pressing Ctrl+x will immediately exit copy mode regardless of which key binding mode you're using.

Copy Mode Workflow

For a smooth copy-paste workflow in tmux:

  1. Enter copy mode with Ctrl+b [
  2. Navigate to text using movement keys
  3. Start selection (Space in Emacs mode, v in Vim mode)
  4. Select text using movement keys
  5. Copy selection (Alt+w in Emacs mode, y in Vim mode)
  6. Exit copy mode automatically or press q
  7. Paste with Ctrl+b ]