Emacs Crash Course

This is a very quick introduction to Emacs.

Once Emacs is open, Emacs commands are prefixed with Ctrl-x (usually written C-x), which means to hold control and press 'x'. This combination is a 'keymap binding', that is, there is a table of commands that follow C-x, which allows different tables to be made for other prefixes (for instanceC-c, C-u, and C-h). The first three commands you should know are:

  • find-file = C-x C-f then type the name/path to the file you want (either to edit an existing one, or type a new name to edit a new one). This will open it in a “buffer” (analogous to a window), and anything you type in there will be saved with…

  • save-buffer = C-x C-s which actually saves into the file. To then close Emacs and get back to your shell (probably bash, I like zsh), do…

  • save-buffers-kill-emacs = C-x C-c which will ask to save any unsaved files, and then close Emacs.

Note the names in the list, those are actual Emacs functions, which can be directly called by typing M-x or ('M' for 'meta', the alt/option key), and then typing the name of the function, of which there are many, you wish to execute.

I would also highly recommend going through Emacs’ built-in tutorial. When you first start Emacs, it should say how to do this, but as a reminder it’s C-h t, hold control and press 'h', then press 't'. Note that it’s not C-h C-t; let go of control before pressing 't'.

References

Since this editor has been in active development and use since the 70's, there are many resources out there. Here's a short list: