Shortcuts to Move Faster in Terminal¶
Nowdays we spend a lot of time in bash shell, typing long and complex commands. You can use the arrow keys up/down/left/right to move the cursor and select commands, but that's not so efficient.
By default, bash command line uses the shortcuts of emacs, so the following commands are mostly from emacs, you can also use the shortcuts of vim by setting set -o vi.
Move¶
Move in Charactor¶
C-b: Movebackone charactor(Cis forCtrl)C-f: Moveforwardone charactor
Move in Word¶
A-f: Moveforwarda word(Ais forAlt)A-b: Movebackwarda word
Move in Line¶
C-a: Move to theaheadof the lineC-e: Move to theendof the line
Edit¶
Cut in Charactor¶
C-d:Deletecurrent charactorBackspace: Delete previous charactorC--: Undo
Cut in Word¶
A-d: Cut from cursor to the end of wordA-Backspace: Cut from cursor to the start of wordC-w: Cut from cursor to previous whitespace
Cut in Line¶
C-k: Cut(kill) from cursor to the end of lineC-x-Backspace: Cut from cursor to the start of line
Paste¶
C-y: Paste(yank) the last cut textA-y(afterC-y): Redo pasting the last cut text
Transpose¶
C-t:Transposethe charactor under the cursor and the one before itEsc-t: Transpose the word under the cursor and the one before it
Search¶
C-p: Retrieve thepreviouscommandC-n: Retrieve thenextcommandC-s: ForwardsearchC-r:ReversesearchC-g: Quit the search mode
Replace(The bang ! commands)¶
!!: Excute last command!top: Excute the most recent command that starts withtop!$: Excute the last word of the previous command!*: Excute the all words of the previous command except the first![pattern]:p: Display the!command result