Emacs Commands Cheat Sheet
Posted : admin On 1/29/2022Shell, Emacs, & Python (oh my!) Cheat Sheet Lawrence David 09.07.06 1 Shell To run these commands, only type in the part after the dollar sign. Replace both arguments and square brackets (don’t leave square brackets in). $ cp oldfile newfile $ mv oldfile newfile $ rm oldfile $ mkdir newdir $ rm -r olddir $ cd destination. Emacs has some great commands that offer aid in recovering or restoring the contents of a file. To abort commands that are either running or have been partially typed, click Ctrl + g. To recover a file whose data might have been lost, use the keys Alt + x to open the mini-buffer and then enter recover-file. Emacs Commands List C = Control M = Meta = Alt Esc Basics C-x C-f 'find' file i.e. Open/create a file in buffer C-x C-s save the file C-x C-w write the text to an alternate name C-x C-v find alternate file C-x i insert file at cursor position C-x b create/switch buffers C-x C-b show buffer list C-x k kill buffer C-z suspend emacs. Emacs-cheat-sheet.md Rule of thumb: when in doubt, C-g it out.
Emacs-cheat-sheet.md In penance for cracking stupid jokes on Twitter, here's my Emacs cheat sheet. Emacs has a steep learning curve, so I've tried to order them by importance so you could learn them in stages.

Motion
|
|
|
|
|
|
|
|
|
|
|
|
Editing
|
|
|
|
|
|
|
|
| Exchange the char before cursor with the character at cursor |
| Exchange the word before cursor with the word at cursor |
| Uppercase the current word |
| Lowercase the current word |
| Capitalize the current word |
Killing and Yanking
Emacs Commands Cheat Sheet Cheat
|
|
|
|
| Kill backward from point to the beginning of the line |
| Kill from point to the end of the current word |
| Kill the word behind point |
| Kill the word behind point, using white space as a word boundary |
| Delete all spaces and tabs around point |
| Yank the top of the kill ring into the buffer at point |
| Rotate the kill ring, and yank the new top |
Keyboard Macros

| Begin saving the chars typed into the current keyboard macro |
| End saving the chars typed into the current keyboard macro |
| Re-execute the last keyboard macro defined |
Completing
| Attempt to perform completion on the text before point |
| List the possible completions of the text before point |
| Insert all completions of the text before point generated by possible-completions |
Manipulating the History
|
|
|
|
|
|
|
|
|
|
| Search backward starting at the current line (incremental) |
| Search forward starting at the current line (incremental) |
| Search backward using non-incremental search |
| Search forward using non-incremental search |
| Insert the n-th argument to the previous command at point |
| Insert the last argument to the previous command |

Rectangles
| Kill the text of the region-rectangle, saving its contents as the 'last killed rectangle' |
| Save the text of the region-rectangle as the 'last killed rectangle' |
| Delete the text of the region-rectangle |
| Yank the last killed rectangle with its upper left corner at point |
| Insert blank space to fill the space of the region-rectangle. This pushes the previous contents of the region-rectangle to the right |
| Insert line numbers along the left edge of the region-rectangle. This pushes the previous contents of the region-rectangle to the right |
| Clear the region-rectangle by replacing all of its contents with spaces |
| Delete whitespace in each of the lines on the specified rectangle, starting from the left edge column of the rectangle |
| Replace rectangle contents with string on each line |
| Insert string on each line of the rectangle |
| Toggle Rectangle Mark mode. When this mode is active, the region-rectangle is highlighted and can be shrunk/grown, and the standard kill and yank commands operate on it |
Miscellaneous
Emacs Cheat Sheet Gnu
|
|
| Abort the current editing command and ring the terminals bell |
| If the metafield char x is lowercase run the command that is bound to uppercase char |
| Metafy the next character typed. For example, ESC-p is equivalent to Meta-p |
| Incremental undo, separately remembered for each line |
| Undo all changes made to this line |
| Perform tilde expansion on the current word |
| Set the mark to the point |
| Swap the point with the mark |
| Move to the next occurance of current character under cursor |
| Move to the previous occurrence of current character under cursor |
| Without argument line is commented, with argument uncommented (if it was commented) |
| When in vi mode, switch to emacs mode |
| When in emacs mode, switch to vi mode |
| Specify the digit to the argument |
Notes

- Based on the cheat sheet from cheat-sheets.org.
- Converted by @erggo.