Key Binding Commands
bind-key
Create or modify key bindings:-n: Bind without requiring the prefix key (root table)-r: Allow key to repeat without pressing prefix again-T: Specify the key table (default: prefix)-N: Add a descriptive note for the binding
bind-key command is implemented in cmd-bind-key.c:54-107 and uses the key_bindings_add() function to register bindings.
unbind-key
Remove key bindings:list-keys
List all key bindings:-1: Show only one binding-N: Show notes/descriptions-T: Filter by key table
Key Tables
Key bindings are organized into tables. From key-bindings.c:104-123, tmux uses a red-black tree structure to manage key tables efficiently.Built-in Key Tables
Using Key Tables
Default Key Bindings
tmux initializes default bindings inkey_bindings_init() (key-bindings.c:347-669). Here are the most important defaults:
Session Management
Window Management
Pane Management
Layout Management
Copy Mode
Copy Mode Keys (Emacs)
Copy Mode Keys (Vi)
Mouse Bindings
tmux includes comprehensive mouse support (key-bindings.c:442-489):Custom Binding Examples
Here are practical custom bindings from example_tmux.conf:Function Key Bindings
Toggle Bindings
Prefix Key Customization
Key Codes
Keys can be specified in several formats:Repeatable Bindings
The-r flag creates repeatable bindings. After pressing the binding once, you can press just the key (without prefix) within the repeat-time window:
KEY_BINDING_REPEAT flag.
Listing and Describing Keys
Binding Best Practices
Avoid conflicts with shell/editor
Avoid conflicts with shell/editor
Don’t bind keys that conflict with your shell or text editor. For example,
C-s is used by shell flow control.Use meaningful mnemonics
Use meaningful mnemonics
Choose key bindings that are easy to remember. For example,
r for reload, | for vertical split.Document your bindings
Document your bindings
Use the
-N flag to add notes to your custom bindings: