Default prefix is Ctrl-b (shown as C-b below)
tmux new -s name # New named session
tmux ls # List sessions
tmux a -t name # Attach to named session
tmux a # Attach to last session
tmux kill-session -t name # Kill specific session
tmux kill-server # Kill all sessions
C-b d # Detach from session
C-b $ # Rename session
C-b s # Session switcher (interactive)
C-b ( # Previous session
C-b ) # Next sessionC-b c # Create new window
C-b , # Rename current window
C-b & # Kill current window (with prompt)
C-b w # List windows (interactive)
C-b n # Next window
C-b p # Previous window
C-b 0-9 # Switch to window 0-9
C-b l # Last active window
C-b f # Find window by nameC-b % # Split vertically (left/right)
C-b " # Split horizontally (top/bottom)
C-b x # Kill current pane
C-b o # Cycle through panes
C-b ; # Last active pane
C-b z # Toggle pane zoom (fullscreen)
C-b ! # Convert pane to window
C-b q # Show pane numbers (then press number to switch)
C-b { # Move pane left
C-b } # Move pane right
C-b Space # Cycle pane layouts
# Arrow key navigation (default)
C-b ← # Move to left pane
C-b ↓ # Move to down pane
C-b ↑ # Move to up pane
C-b → # Move to right pane
# Resize panes (hold C-b + Alt, press arrow keys)
C-b M-← # Resize left
C-b M-↓ # Resize down
C-b M-↑ # Resize up
C-b M-→ # Resize right# Character/Line Movement
h j k l # Left, down, up, right
0 # Beginning of line
^ # First non-blank character
$ # End of line
gg # First line of file
G # Last line of file
5G or :5 # Go to line 5
# Word Movement
w # Next word start
W # Next WORD start (skip punctuation)
e # Next word end
b # Previous word start
B # Previous WORD start
# Screen Movement
C-f # Page down
C-b # Page up
C-d # Half page down
C-u # Half page up
H # Top of screen
M # Middle of screen
L # Bottom of screen
zz # Center cursor line
zt # Cursor line to top
zb # Cursor line to bottom
# Search Movement
/pattern # Search forward
?pattern # Search backward
n # Next match
N # Previous match
* # Search word under cursor forward
# # Search word under cursor backward
% # Jump to matching bracket/parenthesis# Insert Mode
i # Insert before cursor
I # Insert at beginning of line
a # Append after cursor
A # Append at end of line
o # Open line below
O # Open line above
ea # Append at end of word
Esc or C-[ # Exit insert mode
# Delete/Change
x # Delete character
X # Delete character before cursor
dd # Delete line
5dd # Delete 5 lines
dw # Delete word
d$ # Delete to end of line
d0 # Delete to beginning of line
dG # Delete to end of file
cc # Change entire line
cw # Change word
c$ # Change to end of line
ciw # Change inside word
ci" # Change inside quotes
ci( # Change inside parentheses
ct. # Change until period
# Copy/Paste
yy # Yank (copy) line
5yy # Yank 5 lines
yw # Yank word
y$ # Yank to end of line
p # Paste after cursor
P # Paste before cursor
"+y # Yank to system clipboard
"+p # Paste from system clipboard
# Undo/Redo
u # Undo
C-r # Redo
. # Repeat last commandv # Visual mode (character)
V # Visual line mode
C-v # Visual block mode
gv # Reselect last visual selection
# In visual mode:
d # Delete selection
y # Yank selection
c # Change selection
> # Indent right
< # Indent left
~ # Toggle case
u # Lowercase
U # Uppercase:w # Save
:w filename # Save as
:q # Quit
:q! # Quit without saving
:wq or :x # Save and quit
:e filename # Open file
:e! # Reload file (discard changes)
:bn # Next buffer
:bp # Previous buffer
:bd # Delete buffer
:ls # List buffersiw # Inside word
aw # Around word (including spaces)
is # Inside sentence
as # Around sentence
ip # Inside paragraph
ap # Around paragraph
i" or i' # Inside quotes
a" or a' # Around quotes
i( or i) # Inside parentheses
a( or a) # Around parentheses
i{ or i} # Inside braces
a{ or a} # Around braces
i[ or i] # Inside brackets
a[ or a] # Around brackets
it # Inside tag (HTML/XML)
at # Around tagC-b [ # Enter copy mode
# In copy mode (vim keybindings):
h j k l # Navigate
/ # Search forward
? # Search backward
n/N # Next/previous search
Space # Start selection
v # Start selection (character)
V # Start selection (line)
C-v # Start selection (block)
y # Copy selection (to tmux buffer)
Enter # Copy and exit copy mode
q # Exit copy mode
C-b ] # Paste from tmux buffer
C-b = # Choose buffer to paste (interactive)# From tmux (your config uses pbcopy):
# 1. Enter copy mode: C-b [
# 2. Select text with Space/v/V
# 3. Copy with y (goes to system clipboard via pbcopy)
# 4. Paste anywhere with system paste (Cmd-V on Mac)
# From vim to system:
"+yy # Copy line to system clipboard
"+5yy # Copy 5 lines to system clipboard
"+yiw # Copy word to system clipboard
"+p # Paste from system clipboard
# Visual mode system copy:
# 1. Select text in visual mode (v/V/C-v)
# 2. Press "+y to copy to system clipboard# Copy from Claude Code to vim/tmux:
# 1. Select text in Claude Code terminal
# 2. Copy with Cmd-C (Mac) or Ctrl-Shift-C (Linux)
# 3. In vim: "+p or in insert mode: Cmd-V
# 4. In tmux: just paste normally (Cmd-V)
# Copy from vim/tmux to Claude Code:
# 1. Use tmux copy mode or vim "+y to get to system clipboard
# 2. Paste in Claude Code with Cmd-V (Mac) or Ctrl-Shift-V (Linux)
# Pro tip: Use tmux's copy mode for selecting across panes
# Pro tip: In vim, set up a leader key mapping for easier clipboard access:terminal or :term # Open terminal in current window
:vert term # Open terminal in vertical split (side-by-side)
:below term # Open terminal below current window
:tab term # Open terminal in new tab
:10term # Open terminal with height of 10 lines
:vert :30term # Vertical terminal with width of 30 columns
:term ++close # Auto-close when process exits
:term ++noclose # Keep open when process exits (default)
:term npm run dev # Run command directly in terminal# Two modes in terminal:
# 1. Terminal-Job mode (default) - Interactive terminal
# 2. Terminal-Normal mode - Navigate with vim commands
# Mode switching:
Ctrl-W N # Enter Terminal-Normal mode (vim navigation)
Ctrl-\ Ctrl-N # Alternative way to Terminal-Normal mode
i or a # Return to Terminal-Job mode (interactive)
# Window navigation from terminal:
Ctrl-W h/j/k/l # Navigate to other windows
Ctrl-W w # Cycle through windows
Ctrl-W : # Enter command mode
Ctrl-W c # Close terminal window
Ctrl-W Ctrl-W # Quick window switch
# In Terminal-Normal mode (after Ctrl-W N):
hjkl # Vim navigation
gg / G # Jump to start/end
/searchterm # Search in terminal output
yy # Yank lines
v + y # Visual select and copy
p # Paste (great for copying commands)
?error # Search backward for errors# SSH into server with tmux
ssh user@server -t "tmux new -s dev || tmux a -t dev"
# In tmux, open vim
vim myproject.py
# In vim, split and run your process
:below term
python manage.py runserver # or any long-running process
# Monitor output while coding:
Ctrl-W N # Enter Normal mode to scroll/search output
/ERROR # Search for errors
Ctrl-W k # Jump back to code
# Make fixes
:w # Save
Ctrl-W j # Back to terminal
Ctrl-C # Stop server
↑ Enter # Restart with up arrow + enter# Open your code
vim src/app.py
# Create test terminal
:vert term # Vertical split for tests
pytest --watch # Run tests in watch mode
# Workflow:
# 1. Write code in left pane
# 2. Save with :w
# 3. Tests auto-run in right pane
# 4. Ctrl-W N to enter Normal mode in terminal
# 5. Search for failures with /FAILED
# 6. Copy error messages with visual mode + y
# 7. Paste into Claude Code for help# Open SQL workspace
vim queries.sql
# Open database terminal
:below 15term # 15-line terminal below
mysql -u root -p mydb # or psql, sqlite3, etc.
# Run queries workflow:
# 1. Write query in vim
yip # Yank inside paragraph (copy query)
Ctrl-W j # Jump to terminal
Ctrl-V # Paste query (or right-click paste)
Enter # Execute
# Copy results back:
Ctrl-W N # Normal mode in terminal
V # Visual line mode
jjj # Select multiple lines
y # Yank results
Ctrl-W k # Back to vim
p # Paste results as comment# Start with your main file
vim server.js
# Set up your workspace:
:tabe .env # Tab for environment config
:vert term # Right split for server
npm run dev
Ctrl-W h # Back to code
:below 10term # Bottom split for git
git status
# Navigate between:
gt / gT # Next/previous tab
Ctrl-W h/j/k/l # Between splits
:tabs # List all tabs
:buffers # List all buffers
# Before disconnecting:
Ctrl-W N # Normal mode in each terminal
:mksession ~/session.vim # Save entire vim session
:xa # Save all and exit
# When reconnecting:
vim -S ~/session.vim # Restore entire workspace!# Open your application
vim app.py
# Start application with logging
:vert term
python app.py 2>&1 | tee debug.log
# In another split for log monitoring
:below term
tail -f debug.log | grep -E "ERROR|WARNING"
# Debug workflow:
# 1. Trigger issue in app
# 2. Ctrl-W j to log terminal
# 3. Ctrl-W N for Normal mode
# 4. /ERROR to find issues
# 5. V to start visual line
# 6. Select relevant lines
# 7. "+y to copy to system clipboard
# 8. Paste into Claude Code for analysis#!/bin/bash
# Save as ~/dev-session.sh
tmux new-session -d -s dev -n main
tmux send-keys -t dev:main "vim" C-m
tmux send-keys -t dev:main ":vert term" C-m
sleep 1
tmux send-keys -t dev:main "npm run dev" C-m
tmux send-keys -t dev:main C-w C-w # Back to vim
tmux new-window -t dev -n logs
tmux send-keys -t dev:logs "tail -f /var/log/app.log" C-m
tmux new-window -t dev -n db
tmux send-keys -t dev:db "mysql -u root -p" C-m
tmux select-window -t dev:main
tmux attach -t dev# Save vim session before detaching
:mksession! ~/.vim_sessions/current.vim
:xa # Save all and exit
Ctrl-b d # Detach tmux
# Restore everything
ssh user@server
tmux a # Attach to tmux
vim -S ~/.vim_sessions/current.vim # Restore vim sessionCtrl-W N # Enter Normal mode
V # Visual line mode
jjj # Select lines
"+y # Copy to system clipboard
# Now paste anywhere with Ctrl-V/Cmd-V# Copy from Claude Code (Ctrl-C/Cmd-C)
# In vim terminal:
Ctrl-W N # Normal mode
"+p # Paste from system clipboard
# OR in Terminal-Job mode:
Ctrl-Shift-V # Direct paste (Linux)
Cmd-V # Direct paste (macOS)-
Persistent terminals across vim sessions:
:terminal ++kill=no # Don't kill process when closing vim
-
Send commands to terminal from vim:
:call term_sendkeys(bufnr('%'), "npm test\<CR>")
-
Auto-scroll terminal output:
:set termwinscroll=100000 # Large scrollback
-
Quick terminal toggle mapping (add to .vimrc):
nnoremap <leader>t :below 10term<CR> nnoremap <leader>vt :vert term<CR>
-
Better terminal colors (add to .vimrc):
let g:terminal_ansi_colors = [ \ '#282828', '#cc241d', '#98971a', '#d79921', \ '#458588', '#b16286', '#689d6a', '#a89984', \ '#928374', '#fb4934', '#b8bb26', '#fabd2f', \ '#83a598', '#d3869b', '#8ec07c', '#ebdbb2' \ ]
# One-liner to SSH and attach/create tmux session
ssh user@server -t "tmux a || tmux new -s main"
# SSH with tmux session name
ssh user@server -t "tmux new -s projectname || tmux a -t projectname"
# Persistent sessions across disconnects
# On server, in tmux:
C-b d # Detach before disconnect
# Later:
ssh user@server
tmux a # Resume exactly where you left off# Multi-pane development setup
tmux new -s dev
C-b % # Split for code editor
vim myfile.py
C-b " # Split for testing
C-b j # Move to test pane
python myfile.py
# Log monitoring setup
C-b c # New window for logs
tail -f /var/log/app.log
C-b p # Back to coding window
# Multiple server management
tmux new -s servers
C-b c # Window per server
ssh server1
C-b c
ssh server2
C-b , # Rename windows for clarity# Quick config file edits
sudo vim /etc/nginx/nginx.conf
:w !sudo tee % # Save file with sudo (if you forgot sudo)
# Search and replace across file
:%s/old/new/g # Replace all occurrences
:%s/old/new/gc # Replace with confirmation
# Jump between files
:e /path/to/file # Open file
C-^ # Toggle between current and last file
:Split filename # Open in horizontal split
:vsplit filename # Open in vertical split
C-w w # Cycle between splits
C-w h/j/k/l # Navigate splits (like tmux!)# Save tmux session layout
C-b C-s # Save session (with tmux-resurrect plugin)
C-b C-r # Restore session
# Without plugins - manual approach:
# Save pane layout
tmux list-windows -F "#{window_layout}"
# Restore: tmux select-layout "layout-string"
# Quick session script
#!/bin/bash
# save as ~/dev-session.sh
tmux new-session -d -s dev
tmux send-keys -t dev 'cd ~/project' C-m
tmux send-keys -t dev 'vim .' C-m
tmux split-window -h -t dev
tmux send-keys -t dev 'npm run dev' C-m
tmux attach -t dev# Synchronize panes (type in all at once)
C-b :setw synchronize-panes on
# Send commands to specific pane
tmux send-keys -t session:window.pane "command" Enter
# Pipe pane output to file
C-b :pipe-pane -o "cat >>~/output.log"
# Search buffer output
C-b [ # Enter copy mode
C-s # Search mode (if configured)# Macros
qa # Start recording macro 'a'
<do stuff>
q # Stop recording
@a # Play macro 'a'
10@a # Play macro 10 times
# Marks
ma # Set mark 'a' at cursor
'a # Jump to line of mark 'a'
`a # Jump to exact position of mark 'a'
:marks # List all marks
# Multiple cursors (without plugin)
C-v # Visual block mode
<select>
I # Insert at beginning
<type>
Esc # Apply to all lines
# Quick fixes
:set paste # Paste mode (preserves formatting)
:set nopaste # Exit paste mode
:noh # Clear search highlighting
:set number # Show line numbers
:set relativenumber # Relative line numbers# Add to ~/.tmux.conf for better vim integration:
set -g escape-time 0 # No delay for escape key
set -g focus-events on # Pass focus events to vim
set -g mouse on # Enable mouse support
# Add to ~/.vimrc for better tmux integration:
set ttimeoutlen=0 # No delay for escape key
set clipboard=unnamed # Use system clipboard
set mouse=a # Enable mouse support
# Better colors in tmux+vim:
# In .tmux.conf:
set -g default-terminal "screen-256color"
# In .vimrc:
set termguicolors# Tmux
C-b c # New window
C-b % # Split vertical
C-b " # Split horizontal
C-b h/j/k/l # Navigate panes
C-b z # Zoom pane
C-b d # Detach
C-b [ # Copy mode
C-b ] # Paste
# Vim
:w # Save
:q # Quit
/pattern # Search
dd # Delete line
yy # Copy line
p # Paste
u # Undo
. # Repeat# Tmux frozen?
C-b :kill-server # Nuclear option
# Vim frozen?
Esc Esc Esc # Get to normal mode
:q! # Force quit
C-z # Suspend to shell
fg # Resume vim
# Lost in vim?
Esc :help # Built-in help
Esc :q # Try to quitPro tip: Print this cheatsheet or keep it open in a tmux pane while you work! Customize your ~/.tmux.conf and ~/.vimrc gradually as you learn what works for you.