In many Computer Science courses at UCSB, you may need to use a basic text editor.
Although both emacs and vi/vim are fine editors, emacs is often a little easier for beginners to learn.
This is not a complete introduction to emacs—it is intended only to get you started, and then refer you to resources where you can learn more.
emacsat the Unix prompt.
When emacs comes up, immediately type first CTRL/X, then CTRL/C. This will take you back to the Unix prompt.
You've just learned your first, and most important lesson: how to get out of emacs. It is also the easiest way to quickly learn how to save files; if you have made any changes, emacs will ask you if you want to save before you exit.
Now, to create or edit a file called "foo.dat", type
at the Unix comand prompt. Emacs should come up with a blank screen if foo.dat doesn't exist yet, or the contents of foo.dat if it already does.
or splits your screen and you see this:
C-h (Type ? for further options)-
That's most all you need to know. Here are two quick troubleshooting tips
To bring up emacs to make changes to ctof.c, type:
This may bring up a new window where you can edit this program.
If there is another program that you prefer, e.g. vim, that is already available on the Cooper Lab (and CSIL) computers, and you already know how to use it (or are willing to take responsibility for learning how) 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.
Here are a few emacs commands that may be helpful to know.
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".
|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-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|
Here's a link to 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.
(These instructions assume you already read through the quickstart above.)
Emacs has a tutorial built right into itself!
Here's the easy way to bring up the tutorial.
emacsat the unix command line).
Copyright (c) 1985 Free Software Foundation, Inc; See end for conditions.
Emacs commands generally involve the CONTROL key (sometimes labeled CTRL or CTL) or the META key (sometimes labeled EDIT or ALT). Rather than write that in full each time, we'll use the following abbreviations:
C-<chr> means hold the CONTROL key while typing the character <chr> Thus, C-f would be: hold the CONTROL key and type f. M-<chr> means hold the META or EDIT or ALT key down while typing <chr>. If there is no META, EDIT or ALT key, instead press and release the ESC key and then type <chr>. We write <ESC> for the ESC key.
Important note: to end the Emacs session, type C-x C-c. (Two characters.) The characters ">>" at the left margin indicate directions for you to try using a command. For instance:
>> Now type C-v (View next screen) to move to the next screen. (go ahead, do it by holding down the control key while typing v). From now on, you should do this again whenever you finish reading the screen.
The slightly harder way to get to the tutorial (but still not too tough)
emacsat the unix command line)
Emacs reference guide (PDF): refcard.pdf
Last update: P. Conrad, 12/03/2013