Imagine if every window in your house was actually just a different view of the same infinite room. You could look through the kitchen window and see your documents. Look through the bedroom window and see your email. Look through the bathroom window and see… well, maybe IRC chat. That’s Emacs.
This chapter is about understanding why Emacs works the way it does. Once you grok this, everything else makes sense. Skip this chapter, and you’ll forever be fighting against Emacs instead of flowing with it.
In your IDE, you have files. In Emacs, you have buffers.
“But wait,” you say, “when I open a file, isn’t that the same thing?”
No. And this difference is everything.
A buffer is just a chunk of text that Emacs is managing. It might be:
🤔 Why Though? Because in Emacs, everything is text, and all text lives in buffers. This means you can use the same editing commands on your code, your email, your chat messages, and your git commit messages. Learn once, use everywhere.
This is where newcomers get confused, because Emacs uses these words differently than every other program:
Let me blow your mind: You can have the same buffer displayed in multiple windows. At the same time. Even in different frames. Change the text in one, it changes in all of them, because they’re all just views of the same buffer.
🚸 IDE Refugee Note: In VS Code, you have tabs that contain files. In Emacs, you have buffers that can be displayed in zero, one, or many windows. This seems insane until you realize you can have your code in one window and scroll to a different part of the same file in another window. Or have your README.md open in two windows with different formatting views.
Try this experiment:
C-x C-f test.txtC-x 2C-x b *scratch*C-x 3 (vertical split)C-x 5 2Congratulations, you’re now looking at multiple windows across multiple frames showing multiple buffers. You’ve entered the Matrix.
See all your buffers:
C-x C-b
This opens the buffer list. It’s not just a list—it’s a buffer itself! Which means you can:
C-s)🎯 Pro Tip: Mark buffers for deletion with d, then execute with x. It’s like a file manager, but for buffers.
Buffers whose names start with * are special. They’re usually not associated with files:
*scratch* - Your playground (we’ll talk about this)*Messages* - Everything Emacs has told you*Completions* - Autocomplete suggestions*Help* - Help information*Buffer List* - The list of buffersThese buffers are part of Emacs itself. They’re how Emacs talks to you.
At the bottom of your Emacs frame is a single line that usually shows something like:
-UUU:----F1 test.txt All L1 (Text)
Below that, when you run commands, a space opens up. That’s the minibuffer. It’s—wait for it—also a buffer! A very special one where you enter commands, search terms, and filenames.
🤔 Why Though? Because if it’s a buffer, you can use all your editing commands in it. Made a typo in a long file path? Use normal editing commands to fix it. Want to paste something? Same commands work. It’s buffers all the way down.
Every buffer has exactly one “major mode” that defines its primary behavior:
python-mode for Python filesmarkdown-mode for Markdownorg-mode for Org filesdired-mode for directory listingsmagit-mode for git operationsThe major mode determines:
See your current major mode in the modeline (that status bar at the bottom of each window).
While a buffer has one major mode, it can have many minor modes. These add functionality:
line-number-mode - Show line numbersauto-fill-mode - Wrap text automaticallyflyspell-mode - Spell checkingcompany-mode - AutocompletionToggle them on and off:
M-x line-number-mode - Toggle line numbersM-x auto-fill-mode - Toggle auto-fill🎯 Pro Tip: C-h m shows all active modes and their key bindings. It’s like a personalized manual for your current buffer.
When Emacs starts, it creates a buffer called *scratch*. This is your playground. It’s not connected to a file. It’s just… there.
;; This buffer is for text that is not saved, and for Lisp evaluation.
;; To create a file, visit it with C-x C-f and enter text in its buffer.
The scratch buffer starts in lisp-interaction-mode. Type some Elisp and press C-j to evaluate it:
(+ 2 2) C-j
4
🚸 IDE Refugee Note: This is like having a REPL always available, but for your editor’s programming language. Imagine if VS Code had a JavaScript console where you could modify VS Code itself while it’s running. That’s what this is.
Here’s where it all comes together. Because everything is a buffer:
Let’s say you’re writing code and need to:
In a traditional IDE:
In Emacs:
C-x 2 to split windowC-h f function-name for docs (opens in new window)M-x compile to run tests (output in a buffer)M-x magit-status for git (in a buffer)M-x mu4e for email (in a buffer)All without leaving Emacs. All using the same key bindings. All searchable with the same commands. All copyable with the same keys.
Since we’re talking philosophy, let’s discuss the kill ring. In Emacs:
But here’s the beautiful part: Emacs remembers everything you’ve killed in a ring. Kill five different things, then cycle through them when yanking:
C-kC-kC-kC-yM-yM-yIt’s not a clipboard; it’s a clipboard history that you can browse.
🤔 Why Though? Because when Emacs was created, there was no system clipboard. So they invented something better. Now we’re stuck with the names “kill” and “yank”, but we get infinite clipboard history, so it’s a fair trade.
In Emacs, you don’t “select” text. You set a “mark” and move the “point” (cursor). The area between them is the “region”.
C-<space>Or use C-x h to mark the whole buffer. Because sometimes you just want it all.
Sometimes, while you’re doing something in the minibuffer, you need to do something else. Emacs lets you recursively enter another command. You’ll see [...] in the modeline when you’re in a recursive edit.
Don’t panic. C-] gets you out. Or C-g if you want to abort completely.
This is like having multiple command lines stacked on top of each other. It sounds confusing, but it’s occasionally brilliant.
By now, you should be starting to see Emacs differently:
This mental model is why Emacs users seem like they’re in a cult. Once you internalize this, every other editor feels like it’s fighting you.
🎮 Try This:
C-x b with partial names to switch between themC-x kC-x C-f and arrow keysC-x 2C-x 3C-x 1C-x 0C-x o*Messages* buffer*scratch**Buffer List*M-x list-packages (spoiler for Chapter 5!)Now that you understand the Emacs philosophy, Chapter 3 will teach you to move through text like a wizard. We’ll cover the movement commands that make Emacs users look like they’re playing a text-based video game.
But here’s the secret: once you understand buffers, windows, and frames, you’ve already learned the hard part. Everything else is just memorizing keys.
“Emacs is not a mere editor; it is a way of life.” —Someone who understood buffers
Once you stop thinking “files” and start thinking “buffers,” you’ll understand why we never leave.