Copy Mode
Copy mode lets you scroll through terminal output, search for text, and copy to a clipboard — all without a mouse.
This is essential when:
- You need to scroll back through long output
- You want to copy error messages or commands
- You're working on a remote server without mouse support
Copy mode is like less or vim for your terminal output.
Entering copy mode
Enter copy mode:
You can now scroll up from your current position.
Copy mode shows output that has scrolled off screen. You can't copy what's currently visible — for that, just select text in your terminal emulator.
Scrolling
Line by line:
Page by page:
Jump to top/bottom:
Searching
Search forward:
Type your search term, press Enter. Press n for next match, N for previous.
Search backward:
Same behavior, but searches upward.
Search supports regex. Use \bword\b for whole-word matches.
Copying text
- Enter copy mode:
Ctrl-b [ - Navigate to start position with arrow keys or search
- Start selection:
Space - Move to end position (text is highlighted)
- Copy selection:
Enter
The text is now in tmux's paste buffer.
Pasting
Paste the last copied text:
This works in any pane or window — paste is session-wide.
Vi mode vs Emacs mode
Copy mode uses vi keys by default. If you prefer emacs:
From command line:
Vi mode is more powerful but requires learning vi. Emacs mode uses familiar arrow keys.
Copy mode commands (vi mode)
| Key | Action |
|---|---|
h j k l | Left, down, up, right |
w b | Forward/backward by word |
0 $ | Start/end of line |
g G | Start/end of buffer |
/ ? | Search forward/backward |
n N | Next/previous search result |
Space | Start selection |
Enter | Copy selection and exit |
q Esc | Exit without copying |
Copy mode commands (emacs mode)
| Key | Action |
|---|---|
↑ ↓ ← → | Arrow keys |
Ctrl-b Ctrl-f | Page up/down |
Ctrl-a Ctrl-e | Start/end of line |
Alt-< Alt-> | Start/end of buffer |
Ctrl-s Ctrl-r | Search forward/backward |
Ctrl-Space | Start selection |
Ctrl-w | Copy selection |
Enter | Copy selection |
Esc | Exit |
Paste buffers
tmux keeps multiple paste buffers. List them:
Use arrow keys to select, Enter to paste.
Copying between sessions
By default, paste buffers are per-session. To share across sessions:
Type: set-buffer -b shared "text"
Then in another session:
Type: paste-buffer -b shared
Configuring scrollback
Increase scrollback history:
Type: set-option -g history-limit 10000
Set this permanently in .tmux.conf: set -g history-limit 10000
Clearing history
Clear scrollback history:
Type: clear-history
Capturing pane
Save entire pane contents to file:
-S -: Start from beginning-E -: End at end> output.txt: Redirect to file
Scrolling with mouse
tmux supports mouse scrolling (requires configuration):
Type: set-option -g mouse on
Now you can:
- Scroll with mouse wheel
- Click to position cursor
- Select and copy with mouse
Mouse mode is convenient but slow. Keyboard-only is faster once learned.
Practical examples
Copy error message:
# Run failing command
npm test
# Enter copy mode
Ctrl-b [
# Search for "Error"
/
Error
# Copy the error
Space (select)
Enter (copy)
# Paste elsewhere
Ctrl-b ]
Copy command from earlier:
# Scroll back
Ctrl-b [
k (up)
# Select command line
Space
0 (start of line)
$ (end of line)
Enter (copy)
# Paste to execute
Ctrl-b ]
Copy mode workflows
Reviewing build output:
- Build runs, scrolls off screen
- Enter copy mode:
Ctrl-b [ - Search for "error" or "warning":
/error - Review each match with
n - Copy specific error to report
Extracting data:
- Run command with table output
- Enter copy mode, navigate to table
- Copy rows with
Space...Enter - Paste into file or spreadsheet
Documenting commands:
- Run successful command sequence
- Enter copy mode
- Copy each command with
0 $ Enter - Paste into documentation
Key bindings summary
| Key | Action |
|---|---|
Ctrl-b [ | Enter copy mode |
Ctrl-b ] | Paste buffer |
Ctrl-b = | Choose buffer |
Space | Start selection |
Enter | Copy selection |
q | Exit copy mode |
/ | Search forward |
? | Search backward |
n N | Next/previous match |
Next: Step 7 → Configuration — Customize tmux with .tmux.conf