In Bash shell, when editting in the command line. There are two different modes, vi mode or Emacs mode. Emacs-mode is the default mode. Below are some of the handy shortcuts in Emacs-mode.
ALT-f: go backward(toward begining of the line)/forward (toward end of the line) a word. Note that
-is a word separator in this case.
Ctrl-E: go to begining/end of the line.
Ctrl-U: delete till the end/begining of the line.
Ctrl-R: search history command. Press
Enterto run a command, or press movement key to edit it.
ALT-D: Delete from current cursor position to the end of the word.
Ctrl-_: Undo edit.
ALT-R: Revert command to original.
Ctrl-W: Delete a word backward. Note that here word is separate by space. So if we have
|indicate cursor) , pressing
Ctrl-Wleave us with only
-is not a word separator in this case. A little inconsistent, IMHO.
License CC BY-NC-ND 4.0