| What | How | Comments | |
|---|---|---|---|
| Run emacs from the shell command line to edit a new or existing file | emacs myfile & | The '&' allows the terminal window from which emacs is called to continue accepting commands. If the '&' is left out, that terminal window will lock up until emacs is closed. |
|
| Add text to a file | Just start typing. | By default, emacs is in "text insert" mode. | |
| Notation | C-f | Means press CTRL and hold it while you type f. |
|
| C-x C-s | Means press CTRL and hold it while you type x and then s. |
||
| Move the cursor (The arrow keys also work.) |
C-f | forward 1 character | To move forward multiple characters, hold down CTRL and hit f several times. |
| C-b | back 1 character | ||
| C-n | next line | ||
| C-p | previous line | ||
| M-> | end of file | ||
| M-< | start of file | ||
| Search | C-s pattern | search for pattern starting from cursor position | To find next occurrence, do C-s again. To find one occurrence after another, hold down CTRL and type one s after another. |
| Deleting | DELETE | delete 1 char | |
| C-k | kill/delete characters from cursor to end-of-line | These characters are 'cut' and put into a buffer which can be pasted with C-y (yank). | |
| Cut and Paste | C-k C-y |
C-k to kut C-y to paste (yank) |
|
| Save file | C-x C-s (Save) C-x C-w (Save As) |
||
| Exit Emacs | C-x C-c | It'll ask you if you want to save or not. | |
| Undo | C-g | Gets you out of any command you are currnetly try to run e.g. search, open, save as, or you hit back space by accident. | Hitting Esc multiple times also does the trick, if you prefer to take out frustration on keyboards :) |
| C-_ | Undo changes to the buffer e.g. typing or deletion. | C-- works in some versions too. | |