01
The essentials
C-a
Beginning of line
beginning-of-lineC-e
End of line
end-of-lineM-b
Back one word
backward-wordM-f
Forward one word
forward-wordC-u
Cut to the beginning
unix-line-discardC-k
Cut to the end
kill-lineC-w
Cut the previous word
unix-word-ruboutM-d
Cut the next word
kill-wordC-y
Paste the last cut
yankM-y
Cycle earlier cuts
yank-popC-r
Search history backward
reverse-search-historyM-.
Insert the last argument
yank-last-argC-_
Undo
undoC-l
Clear and redraw
clear-screen02
Movement
Characters and words
- C-b
- Back one character
backward-char - C-f
- Forward one character
forward-char - M-b
- Back one word
backward-word - M-f
- Forward one word
forward-word - C-]
- Move to the next occurrence of a character
character-search
Lines and history
- C-a
- Beginning of line
beginning-of-line - C-e
- End of line
end-of-line - C-p
- Previous history entry
previous-history - C-n
- Next history entry
next-history - M-<
- First history entry
beginning-of-history - M->
- Current, unfinished line
end-of-history
03
Editing
Cut and paste
- C-u
- Cut backward to the beginning of the line
unix-line-discard - C-k
- Cut forward to the end of the line
kill-line - C-w
- Cut the previous whitespace-delimited word
unix-word-rubout - M-DEL
- Cut the previous Readline word
backward-kill-word - M-d
- Cut through the end of the next word
kill-word - C-y
- Paste the newest cut
yank - M-y
- After yanking, replace it with the previous cut
yank-pop
Readline calls cutting killing, pasting yanking, and its clipboard history the kill ring.
Change
- C-d
- Delete the character under the cursor
delete-char - C-t
- Transpose two characters
transpose-chars - M-t
- Transpose two words
transpose-words - M-u
- Uppercase the word
upcase-word - M-l
- Lowercase the word
downcase-word - M-c
- Capitalize the word
capitalize-word - C-_
- Undo one change
undo - M-r
- Undo every change to this history line
revert-line - C-v
- Insert the next character literally
quoted-insert
04
History and completion
Find and reuse
- C-r
- Incrementally search backward
reverse-search-history - C-s
- Incrementally search forward
forward-search-history - M-p
- Search backward for a string
non-incremental-reverse-search-history - M-n
- Search forward for a string
non-incremental-forward-search-history - M-.
- Insert the previous command's last argument; repeat to go further back
yank-last-arg - C-o
- Run this line, then fetch the following history entry
operate-and-get-next
C-s may freeze output when terminal flow control is enabled. C-q resumes it; stty -ixon disables it.
Complete
- TAB
- Complete the text before the cursor
complete - M-?
- List possible completions
possible-completions - M-*
- Insert every possible completion
insert-completions
05
Further along
Mark and region
- C-@
- Set the mark
set-mark - C-x C-x
- Exchange the cursor and mark
exchange-point-and-mark
Repeat
- M-0…9
- Give the next command a numeric argument
digit-argument - C-x (
- Start recording a keyboard macro
start-kbd-macro - C-x )
- Stop recording
end-kbd-macro - C-x e
- Run the last macro
call-last-kbd-macro
Control
- C-g
- Abort the current editing command
abort - C-l
- Clear the screen and redraw the line
clear-screen - M-#
- Comment out and accept the line
insert-comment - C-x C-r
- Reload the Readline init file
re-read-init-file - M-x
- Run a command by name
execute-named-command
06
Your bindings
Ask Readline
bind -P
bind -q backward-kill-word
bind -v
bind -P prints functions and bindings. bind -q finds the keys for one function. bind -v prints variables and values.
~/.inputrc
set editing-mode emacs
set completion-ignore-case on
set show-all-if-ambiguous on
Readline starts in Emacs mode. Use set editing-mode vi for its vi-style insertion and command modes.