Emacs in 5 Minutes for Python and JavaScript Programmers
Part 1: Emacs in 5 Minutes — Or Why Ctrl-g Is Your Best Friend
"I just wanted to edit a file."
That’s how it starts. You install Emacs. You open it. Nothing moves. Every shortcut you know from VS Code, Sublime, or Vim? Useless. And when you try to quit, instead of saving, your computer starts beeping at you.
Welcome to Emacs.
But don’t worry. In this first part, we’ll show you how to:
- Open and save files (spoiler: it’s about buffers, not files)
- Split your window like a pro
- Move around without losing your mind
- Undo, redo, and undo the redo
- Abort anything with a glorious keystroke:
C-g
Mnemonic Decoding: What Does C-x C-f
Even Mean?
Let’s decode a few things first:
C-x
: Think of this as "system-level command". It usually starts things like save, open, close.C-c
: These are often for plugin or mode-specific commands (like Org mode, or SLIME for Lisp).M-
: That’s the Meta key (usuallyAlt
orOption
on Mac).RET
: That’s Return, aka your Enter key.
So when someone says C-x C-f
, they mean:
"Hold Control, press x, then while still holding Control, press f."
Mnemonic: C-x C-f
→ eXecute File
You vs. Emacs: The First Duel
You want to open a file? Think:
"I want to open 'notes.txt' inside Emacs"
Then:
- Command:
C-x C-f
- Type:
~/projects/notes.txt
- Press:
RET
You’re not editing the file directly. You’re editing a buffer. Buffers are the way Emacs thinks about "documents." You can have a hundred of them open. Some shown, some not. That’s both its power and its madness.
Buffers Are Not Tabs
Think of buffers as invisible tabs. They don’t show up. You have to ask for them. Like so:
- See all buffers:
C-x C-b
- Switch to another:
C-x b
(then type the name) - Kill a buffer:
C-x k
Mnemonic:
b
→ bufferk
→ kill (don’t worry, the file lives on until you save it)
Abort Everything: The Holy C-g
If you remember one thing today:
If Emacs gets stuck, or you press the wrong keys, slam C-g
.
It cancels the current command, dialog, search, anything.
It’s your emergency exit.
Windows: Yes, Emacs Has Them (And They're Great)
Want to see two files side-by-side?
- Split horizontally:
C-x 3
- Split vertically:
C-x 2
- Move between them:
C-x o
(o for other) - Close current window:
C-x 0
- Close all but this one:
C-x 1
Pro tip: Buffers stay open even if the window closes.
Part 2: Editing Without Tears — Moving, Killing, Yanking, Undoing
"Where is my cursor? What did I just do?"
Now that you’ve opened files (buffers) and made peace with invisible tabs, let’s get serious: editing.
And yes, you can use arrow keys. But if you're a Python or JavaScript programmer, you love efficiency. Welcome to fast, composable editing.
Movement Cheatsheet
Action | Key | Mnemonic |
---|---|---|
Left | C-b | back |
Right | C-f | forward |
Up | C-p | previous |
Down | C-n | next |
Line Start | C-a | alpha / anchor |
Line End | C-e | end |
Page Down | C-v | view down |
Page Up | M-v | meta view up |
Want Vim-style motion? You can install evil-mode
. But you’ll miss Emacs elegance.
Mark and Region: Emacs' Version of Selecting Text
Say you want to copy a block of code.
"I want to mark from here to there."
- Set mark:
C-SPC
- Move somewhere
- Copy:
M-w
- Cut:
C-w
- Paste:
C-y
(yank) - Cycle through pastes:
M-y
Alt-way:
Use Shift + movement keys (e.g., S-C-n
) to mark while moving.
Killing Isn’t Murder
Emacs uses the term "kill" where others use "cut" or "delete." But everything goes into the kill ring, so you can yank it back. Multiple times.
You can even navigate your kills like a history: C-y M-y
to cycle backward.
Undo/Redo: Better With Undo-Tree
By default:
- Undo:
C-/
orC-x u
- Redo: not intuitive. Use
undo-tree
package.
With undo-tree
:
- Activate tree:
C-x u
- Move with arrows, restore with
RET
, quit withq
Part 3: Pimp Your Emacs — Buffers, Packages, Org-Mode and You
"Why does my Emacs look like 1995?"
Good question. Emacs is minimal by default. But you control it. Through two files:
~/.emacs.d/init.el
: The startup script.~/.emacs.d/myinit.org
: Your literate config (more readable, better structured).
Let’s unpack them.
The init.el
Bootstraps Everything
This file sets up your package archives, installs use-package
, and loads your real config from myinit.org
.
(require 'package)
(setq package-archives '(("melpa" . "https://melpa.org/packages/")
("gnu" . "https://elpa.gnu.org/packages/")))
(package-initialize)
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(require 'use-package)
(setq use-package-always-ensure t)
(org-babel-load-file (expand-file-name "myinit.org" user-emacs-directory))
myinit.org
: Literate Configuration FTW
Why myinit.org
? Because instead of sifting through 2,000 lines of .el
code, you split your config into sections, annotate it, document what’s going on, and execute code blocks inline.
You write in Org-mode, use #+BEGIN_SRC emacs-lisp
, and load everything automatically.
Want themes?
(use-package sweet-theme
:init (load-theme 'sweet t))
Need helpful key hints?
(use-package which-key
:config (which-key-mode))
Want fuzzy search with swiper
?
(use-package swiper
:bind (("C-s" . swiper)
("M-x" . counsel-M-x)))
Need tabs?
(use-package tabbar
:config (tabbar-mode 1))
Why This Is Better Than Doom (Sometimes)
Doom Emacs is pre-configured. Fast, beautiful, powerful. But not yours. myinit.org
is your Emacs. It grows with you. You understand every package, every shortcut. It’s like building your own terminal setup from scratch vs. installing zsh + Oh My Zsh.
Use My Setup
For the start, you can in your home folder git clone my .emacs.d
folder and start coding in JavaScript, TypeScript, or Python, (or Common Lisp).
Simply do:
# after installation of emacs, emacs will have created
# a `.emacs.d` folder in your $HOME.
# Back it up:
mv ~/.emacs.d ~/.emacs.d.orig
# and simply git clone my dot folder
git clone git@github.com:gwangjinkim/.emacs.d.git
# or:
git clone https://github.com/gwangjinkim/.emacs.d.git
# after this, if you start `emacs`, my configurations will be
# taken over and the packages requested in my `.emacs.d/init.el` and
# `.emacs.d/myinit.org` file will be installed
There are, however, for seamless functionality, environment variables to be set.
(In the current state, the best would be to ask ChatGPT what you have to set up.)
I will explain it in the next article.
What’s Next?
Now that we have:
- Navigated buffers and windows
- Edited with pro shortcuts
- Built a literate config in
myinit.org
You’re ready for:
Part 4: Org-mode Mastery
Writing, planning, capturing ideas, journaling, publishing — all from the same keyboard.
Part 5: Python & JS Debugging in Emacs
Interactive REPLs, in-buffer breakpoints, dap-mode
, and SLIME/CIDER.
Part 6: Living REPL Workflows
Why Emacs + REPL = the ultimate coding Zen for Lisp, Python, and more.
[I will add a link to the next article here!]
Stay tuned — and keep your pinky finger near C-g
. You’ll need it.