GNU Readline Keybindings Cheatsheet
GNU Readline is the input library used by bash, zsh, psql, python REPL, and many CLI tools. The default mode is Emacs mode (switch with set -o emacs; toggle to vi mode with set -o vi).
Movement
(| = cursor position)
| Shortcut | Action | Mnemonic | Before | After |
|---|
Ctrl+A | Start of line | A = beginning | hello| world | |hello world |
Ctrl+E | End of line | E = ending | hello| world | hello world| |
Ctrl+F | Forward one character | F = forward | hel|lo world | hell|o world |
Ctrl+B | Backward one character | B = backward | hell|o world | hel|lo world |
Alt+F | Forward one word | F = far forward | hello |world | hello world| |
Alt+B | Backward one word | B = back | hello |world | |hello world |
Ctrl+XX | Toggle cursor ↔ start | — | hello| world | |hello world |
Comparison — Opposite Pairs
| Forward | Backward |
|---|
Ctrl+A — Start of line | Ctrl+E — End of line |
Ctrl+F — Forward one char | Ctrl+B — Backward one char |
Alt+F — Forward one word | Alt+B — Backward one word |
Comparison — Similar Pairs (Same Action)
| Keybinding | Also Known As |
|---|
Ctrl+XX — Toggle cursor ↔ start | No direct equivalent |
Deletion
(| = cursor position)
| Shortcut | Action | Mnemonic | Before | After |
|---|
Ctrl+W | Delete word backward | W = Word backward | hello world| foo | hello |foo |
Alt+D | Delete word forward | D = forward (destreza/right) | hello |world foo | hello |foo |
Alt+Backspace | Delete word backward (same as Ctrl+W) | — | hello world| foo | hello |foo |
Ctrl+U | Delete from cursor to start of line | U-turn backward to start | hello world |foo | |foo |
Ctrl+K | Delete from cursor to end of line | K = right side → delete right | hello| world foo | hello| |
Ctrl+D | Delete char under cursor / EOF | — | hell|o world | hel| world |
Comparison — Opposite Pairs
| Forward Delete | Backward Delete |
|---|
Ctrl+D — Delete char forward | Backspace — Delete char backward |
Alt+D — Delete word forward | Ctrl+W / Alt+Backspace — Delete word backward |
Ctrl+K — Delete to end of line | Ctrl+U — Delete to start of line |
Comparison — Similar Pairs (Same Action)
| Keybinding | Also Known As |
|---|
Alt+Backspace — Delete word backward | Ctrl+W |
Kill / Yank (Cut / Paste)
| Shortcut | Action |
|---|
Ctrl+Y | Yank (paste) the last killed text |
Alt+Y | Cycle through kill ring (after Ctrl+Y) |
All deletion commands above "kill" (cut) into a ring buffer. Ctrl+Y pastes the most recent kill; Alt+Y cycles older entries.
History
| Shortcut | Action |
|---|
Ctrl+P / ↑ | Previous command |
Ctrl+N / ↓ | Next command |
Ctrl+R | Incremental search backward through history |
Ctrl+S | Incremental search forward (if enabled) |
Alt+P | Non-incremental search backward |
Alt+N | Non-incremental search forward |
Alt+< | First history entry |
Alt+> | Last history entry |
Alt+. | Insert last argument of previous command |
Comparison — Opposite Pairs
| Backward / Previous | Forward / Next |
|---|
Ctrl+P — Previous command | Ctrl+N — Next command |
Ctrl+R — Reverse search | Ctrl+S — Forward search |
Alt+P — Non-incremental backward | Alt+N — Non-incremental forward |
Alt+< — First entry | Alt+> — Last entry |
Undo / Repeat
| Shortcut | Action |
|---|
Ctrl+_ or Ctrl+X Ctrl+U | Undo last edit |
Alt+R | Undo all changes on current line |
Transpose (Swap)
| Shortcut | Action |
|---|
Ctrl+T | Swap two characters (char under cursor with char before it) |
Alt+T | Swap two words (word before cursor with word after) |
Case Change
| Shortcut | Action |
|---|
Alt+U | Uppercase next word (from cursor to end of word) |
Alt+L | Lowercase next word |
Alt+C | Capitalize next word (first char uppercase, rest lowercase) |
Macros
| Shortcut | Action |
|---|
Ctrl+X ( | Start recording keyboard macro |
Ctrl+X ) | Stop recording keyboard macro |
Ctrl+X e | Execute last recorded macro |
Miscellaneous
| Shortcut | Action |
|---|
Ctrl+L | Clear screen (same as clear) |
Ctrl+X Ctrl+E | Open current line in $EDITOR |
Alt+Tab | Insert completion (bash programmable completion) |
Ctrl+I | Tab (same as Tab key) |
Ctrl+M | Enter (same as Enter key) |
Numeric Argument Prefix
Press Alt+<N> before any command to repeat it N times.
| Example | Result |
|---|
Alt+5 Alt+D | Delete 5 words forward |
Alt+10 Ctrl+F | Move forward 10 characters |
Alt+3 Ctrl+W | Delete 3 words backward |
Alt+100 Ctrl+B | Move backward 100 characters |
Official Reference