Command Editing Tricks

  • Ctrl-a moves to beginning of line
  • Ctrl-e moves to end of line
  • Ctrl-u deletes to beginning of line
  • Ctrl-k deletes to end of line
  • Ctrl-arrow moves left or right by word

Command line editing
Combining command line editing with history is great way to easily modify previously run commands. The default key bindings in bash are the same as those in the text editor emacs; vi-style bindings are also available for use. To enable them, run the command set -o vi. To make the change permanent, and that command to your .bashrc file so that it is run whenever bash starts.

The following table shows the emacs-style bindings with their corresponding vi-style bindings.

Ctrl-Left arrowEsc,b
Ctrl-Right arrowEsc,w

Using the Home and End keys work to move to the beginning or end of the line as well.

To view all key bindings, run the bind -p command. Where is shows a \C, this signifies the Ctrl Key. \M
signifies the meta key, or Alt.


“\C-I”: clear-screen – Use Ctrl-I to clear off the screen.
“\M-I”: downcase-word – Use Alt-I to change a word from upper-case to lower-case. Useful when you didn’t realize you had the Caps Lock on.

Leave a Comment

%d bloggers like this: