CS 105

A Quick Introduction to Emacs

Why Emacs?

If you've used VS Code, you already know the appeal of an editor that does everything—editing, debugging, version control, maybe even making coffee. Emacs is the original "does everything" editor. It's been around since the 1970s, it runs everywhere, and people have been extending it with new features for decades.

So why learn another editor when VS Code exists?

Here's the thing: VS Code is great when you're working on your own machine with a nice GUI and plenty of resources. But in the real world of computer systems, you'll often find yourself logging into remote servers, embedded devices, or stripped-down containers where VS Code just isn't an option. Sometimes all you have is a terminal and a dream.

That's where knowing a terminal-based editor becomes essential. Emacs (along with its cousins nano and vim) works anywhere you can get a terminal—which is basically everywhere.

Getting Started

To edit a file, say, foo.c, just type the following command at your terminal prompt on wilkes:

emacs foo.c

You'll see Emacs open up in your terminal. Don't panic! It looks different from VS Code, but the basics are surprisingly straightforward.

The Good News: Normal Things Work

Here's the reassuring part—a lot of things work the way you'd expect:

  • Arrow keys move the cursor around
  • Backspace/Delete delete characters
  • Page Up/Page Down scroll through the file
  • Home/End go to the beginning/end of the line
  • You can just start typing to insert text

So if you need to make a quick edit, you can often just... do it. No special modes, no incantations required.

The Essential Commands

Emacs uses modifier keys for commands: C- means hold Control, and M- means hold Meta (which is usually Alt or Escape on modern keyboards).

Here are the commands you actually need to know:

C-x C-s     Save the file
C-x C-c     Exit Emacs
C-g         Cancel whatever you're doing (the "never mind" key)

That's it. With just those three, you can edit files and get out alive.

If Emacs ever seems stuck or confused, mash C-g a few times. It's the universal "stop that and calm down" command.

A Few More Handy Commands

Once you're comfortable with the basics, these are nice to know:

C-x C-f     Open a file (Emacs calls this "find file")
C-s         Search forward (press C-s again to find next match)
C-a         Go to beginning of line
C-e         Go to end of line
C-k         Kill (cut) from cursor to end of line
C-y         Yank (paste) what you just killed
C-_         Undo (yes, that's Control-underscore)

The Built-in Tutorial

Emacs has an excellent built-in tutorial. When you have some time, launch Emacs and press:

C-h t

This starts an interactive tutorial that teaches you Emacs by having you actually use it. It takes maybe 30 minutes and is genuinely well done.

Getting Help

Emacs has extensive built-in help:

C-h ?       Show help options
C-h k       Describe what a key does (then press the key)
C-h a       Search for commands by keyword

Exiting (The Most Important Part)

Let's be real: the first time you're in an unfamiliar editor, the main question is "how do I get out?"

C-x C-c

That's Control-x, then Control-c. If you have unsaved changes, Emacs will ask if you want to save them.

If you ever get really stuck, you can always close the terminal window, but try C-x C-c first—it's more dignified.

Going Further

This page just scratches the surface. Emacs can do syntax highlighting, code completion, run shells, send email, browse the web, and approximately one million other things.

When you're ready to learn more:

But for now? You know how to open a file, edit it, save it, and exit. That's enough to get real work done.

Happy editing!

(When logged in, completion status appears here.)