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-b
andALT-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-A
andCtrl-E
: go to begining/end of the line.Ctrl-K
andCtrl-U
: delete till the end/begining of the line.Ctrl-R
: search history command. PressEnter
to 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-W
leave us with onlypython
.-
is not a word separator in this case. A little inconsistent, IMHO.