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.
Shortcuts#
ALT-bandALT-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-D: delete one character to the right of the cursor.Ctrl-AandCtrl-E: go to begining/end of the line.Ctrl-KandCtrl-U: delete till the end/begining of the line.Ctrl-R: search history command. PressEnterto 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 havepython util/test.py|(|indicate cursor) , pressingCtrl-Wleave us with onlypython.-is not a word separator in this case. A little inconsistent, IMHO.