Emacs Help


Starting emacs

To bring up emacs to create or make changes to a file named xyz.cpp, type:

emacs xyz.cpp

This may bring up a new window where you can edit this file.

Do I have to use emacs in this class?

If there is another program that you prefer, e.g. vim, that is already available on the Phelps 3525 (and CSIL) computers, and you already know how to use it or you are willing to take responsibility for learning how (here's a vi tutorial) that's fine. So, no, you don't have to use emacs, specifically. However you will need to learn some editor that works on the lab computers. Working only on your own PC or Mac at home will not be sufficient.

By the way, knowing how to use either vi/vim or emacs is really a kind of a "basic skill" that every software developer should have in his/her toolkit. So if you don't already know one of those editors, now is as good a time as any to start learning one of them.

Some emacs commands

Here are a few emacs commands that may be helpful to know.

Remember that:

C-x is called "control-X" and means "hold down the control or Ctrl key while typing the letter x"
C-x 1 means "type control-X, then type the number 1".
C-x C-c means "type control-X then type control-C".

Keystroke Command
C-x 1 If there are multiple windows, get rid of the other ones.
I only want the one the cursor is in right now.
Arrow Keys Used to move around
Delete/Backspace Deletes the previous character
C-d Deletes the character immediately under the cursor
C-x C-w Save As
C-x C-s Save
C-x C-c Exit emacs (it will ask if you want to save)
C-g Cancel current command ("get me out of trouble")
C-k Kill (delete) the current line

An emacs reference

Here's a PDF File with lots more emacs commands—it is suitable for printing on a single sheet of paper (front and back) and having handy while you work in emacs.


Thanks to Phill Conrad for most of this page!