Emacs-for-Goodness-Sake

Chapter 1: First Steps Into the Infinite

Or: How to Open, Edit, and Save a File Without Having a Breakdown

Let me guess. You’ve just opened Emacs for the first time, and you’re staring at a screen that looks like it hasn’t changed since 1985. There’s probably a cartoon gnu staring back at you. You tried to quit, but Esc didn’t work. Neither did Ctrl+Q. You might have even tried typing “exit” or “quit” in desperation.

Welcome to Emacs! Where the learning curve is a cliff, but the view from the top is spectacular.

Installing Emacs (If You Haven’t Already Rage-Quit)

Let’s make sure you have a decent version of Emacs installed. You want Emacs 27 or later—anything older and you’re just punishing yourself unnecessarily.

macOS

brew install emacs

Or if you want the GUI version with native compilation (faster, shinier):

brew tap d12frosted/emacs-plus
brew install emacs-plus@30 --with-native-comp

Linux

# Debian/Ubuntu
sudo apt-get install emacs

# Fedora
sudo dnf install emacs

# Arch (because of course you use Arch)
sudo pacman -S emacs

Windows

Download from gnu.org, or better yet, use WSL2 and install the Linux version. Trust me on this one.

🚸 IDE Refugee Note: Yes, the installation is this simple. No, there’s no 2GB download. No, you don’t need to sign in with an account. Emacs predates the concept of “activation keys” by about 20 years.

Your First Trauma: Understanding C- and M-

Before we go any further, we need to talk about notation. Emacs documentation uses:

So when you see C-x C-s, that means:

  1. Hold Control and press x
  2. Keep holding Control and press s

When you see C-x s, that means:

  1. Hold Control and press x
  2. Release Control
  3. Press s by itself

🤔 Why Though? The “Meta” key comes from ancient Lisp machines that had actual Meta keys. Your keyboard doesn’t have one, so we use Alt. Or Escape. Yes, pressing Escape and then the key also works. No, I don’t know anyone who does it that way. Yes, it’s there if you’re using Emacs on your phone for some reason.

Actually Opening a File

Ready? Here’s how to open a file:

C-x C-f

This runs find-file. You’ll see a prompt at the bottom of the screen (that’s called the minibuffer, by the way). Type a filename and press Enter.

🎯 Pro Tip: You can use Tab for autocompletion in the minibuffer. It’s not as fancy as your IDE’s fuzzy finder (yet), but it works.

The Four Horsemen of Basic Editing

You can use arrow keys. It’s fine. We won’t judge you. (We’re totally judging you, but you’ll learn the proper keys soon enough.)

For now, just know:

🚸 IDE Refugee Note: There’s no “insert mode” vs “command mode” like in Vim. You’re always in insert mode. Commands are done with key combinations. This will feel weird for exactly three days, then it’ll feel natural.

Saving Your Work

C-x C-s

That’s it. File saved. You’ll see a message in the minibuffer confirming it.

Want to “Save As” with a different name?

C-x C-w

(The ‘w’ stands for “write”, because of course it does.)

The Undo That Makes Sense (Eventually)

C-/ or C-_ or C-x u all undo. Why three ways? Because different keyboards make different keys hard to reach, and Emacs has been around long enough to have opinions about all of them.

But here’s where it gets interesting: Emacs has infinite undo. And I mean infinite. You can undo back to when you opened the file. Then—and this is the mind-bending part—you can undo your undos.

🤔 Why Though? In Emacs, undo is just another action that can be undone. If you undo too far, just break the undo chain (by moving the cursor or typing something) and then undo again—you’ll start undoing your undos. It’s undo all the way down.

How to Quit (The Most Important Command)

To quit Emacs:

C-x C-c

If you have unsaved changes, it’ll ask if you want to save them.

To cancel a command that’s in progress:

C-g

This is your escape hatch. Memorize it. When Emacs is doing something weird and you don’t know why, C-g is your friend.

Your First Taste of Power: Multiple Files

Here’s where things get interesting. Open a second file:

C-x C-f another-file.txt

Now you have two files open. Switch between them with:

C-x b

This runs switch-to-buffer. You’ll see a list of open buffers (files). Type part of the name and hit Tab to autocomplete.

🎮 Try This:

  1. Open three different files
  2. Switch between them using C-x b
  3. Make changes to all three
  4. Save all modified files at once with C-x s
  5. Feel slightly powerful

The Help System (Your New Best Friend)

Emacs has the most comprehensive built-in help system of any software I’ve ever used. And it needs it.

🎯 Pro Tip: Accidentally hit a key combination and something weird happened? Hit C-h l (that’s lowercase L) to see the last 300 keystrokes you typed. It’s like a flight recorder for your editing session.

Let’s Make It Look Less Like 1985

Add this to your ~/.emacs or ~/.emacs.d/init.el file (create it if it doesn’t exist):

;; Make Emacs less ugly
(menu-bar-mode -1)          ; Disable the menu bar
(tool-bar-mode -1)          ; Disable the tool bar
(scroll-bar-mode -1)        ; Disable the scroll bar
(global-display-line-numbers-mode 1)  ; Show line numbers

;; Make it less beepy
(setq ring-bell-function 'ignore)

;; Show matching parentheses
(show-paren-mode 1)

;; Enable mouse support in terminal
(xterm-mouse-mode 1)

;; Make the cursor a bar instead of a block
(setq-default cursor-type 'bar)

Restart Emacs (C-x C-c to quit, then open it again), and it’ll look slightly more modern. We’ll do much more customization later, but this gets you started.

Your First Workflow

Let’s put it all together. Here’s a simple workflow:

  1. Open Emacs: emacs
  2. Open a file: C-x C-f myfile.txt
  3. Type some text
  4. Save: C-x C-s
  5. Open another file: C-x C-f another.txt
  6. Type more text
  7. Switch back to first file: C-x b myf<Tab><Enter>
  8. Make changes
  9. Save all modified files: C-x s
  10. Quit: C-x C-c

Congratulations! You’re now more productive in Emacs than 50% of people who try it and give up immediately.

What’s Next?

In the next chapter, we’ll explore why Emacs thinks about text differently than every other editor you’ve used. We’ll talk about buffers, windows, and frames, and why understanding these concepts will make everything else click.

But for now, practice these basics. Open some files. Edit them. Save them. Get comfortable with C-g when things go wrong.

And remember: every Emacs user was once where you are now, staring at this bizarre program and wondering why anyone would subject themselves to this. The answer, as you’ll discover, is that Emacs isn’t just a text editor—it’s a text editing environment. And once you start shaping that environment to your will, you’ll understand why some of us never leave.


🎮 Chapter 1 Exercises:

  1. The Basics: Open three files, edit all of them, and save them all with a single command
  2. The Explorer: Use C-h k to find out what C-x C-b does, then try it
  3. The Time Traveler: Make a bunch of edits, undo them all, then undo your undos to get them back
  4. The Seeker: Use the tutorial (C-h t) for 15 minutes—it’s actually good!

“Emacs is the only software that I’ve used for 30 years and am still discovering new features.” —Anonymous Emacs User (could be any of us, really)