Line-Edit Mode
Line-edit mode emulates many features of the vi and emacs editors. The history list is treated like a file. When the editor is invoked, you type editing keystrokes to move to the command line you want to execute. You can also change the line before executing it. When you’re ready to issue the command, press the Enter key.
Select an editor with either set -o vi or set -o emacs ; assignment to the VISUAL or EDITOR variables has no effect. Note that vi starts in input mode; to type a vi command, press the Escape key first.
Common editing keystrokes
vi | emacs | Result |
---|---|---|
k | Ctrl-P | Get previous command. |
j | Ctrl-N | Get next command. |
/
| Ctrl-R
| Get previous command
containing |
h | Ctrl-B | Move back one character. |
l | Ctrl-F | Move forward one character. |
b | ESC-B | Move back one word. |
w | ESC-F | Move forward one word. |
X | DEL | Delete previous character. |
x | Ctrl-D | Delete character under cursor. |
dw | ESC-D | Delete word forward. |
db | ESC-H | Delete word backward. |
xp | Ctrl-R | Transpose two characters. |
Get Linux in a Nutshell, 6th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.