Keyboard shortcuts

Other topics

Remarks:

bind -P show all configured shortcuts.

Recall Shortcuts

ShortcutDescription
Ctrl + rsearch the history backwards
Ctrl + pprevious command in history
Ctrl + nnext command in history
Ctrl + gquit history searching mode
Alt + .use the last word of the previous command
repeat to get the last word of the previous + 1 command
Alt + n Alt + .use the nth word of the previous command
!! + Returnexecute the last command again (useful when you forgot sudo: sudo !!)

Editing Shortcuts

ShortcutDescription
Ctrl + amove to the beginning of the line
Ctrl + emove to the end of the line
Ctrl + kKill the text from the current cursor position to the end of the line.
Ctrl + uKill the text from the current cursor position to the beginning of the line
Ctrl + wKill the word behind the current cursor position
Alt + bmove backward one word
Alt + fmove forward one word
Ctrl + Alt + eshell expand line
Ctrl + yYank the most recently killed text back into the buffer at the cursor.
Alt + yRotate through killed text. You can only do this if the prior command is Ctrl + y or Alt + y.

Killing text will delete text, but save it so that the user can reinsert it by yanking. Similar to cut and paste except that the text is placed on a kill ring which allows for storing more than one set of text to be yanked back on to the command line.

You can find out more in the emacs manual.

Job Control

ShortcutDescription
Ctrl + cStop the current job
Ctrl + zSuspend the current job (send a SIGTSTP signal)

Macros

ShortcutDescription
Ctrl + x, (start recording a macro
Ctrl + x, )stop recording a macro
Ctrl + x, eexecute the last recorded macro

Custome Key Bindings

With the bind command it is possible to define custom key bindings.

The next example bind an Alt + w to >/dev/null 2>&1:

bind '"\ew"':"\" >/dev/null 2>&1\""

If you want to execute the line immediately add \C-m (Enter) to it:

bind '"\ew"':"\" >/dev/null 2>&1\C-m\""

Contributors

Topic Id: 3949

Example Ids: 13765,13766,13767,18184,18185

This site is not affiliated with any of the contributors.