Get back to something
SPC , and type part of a name. Start with b SPC, f SPC or m SPC to see only buffers, recent files or bookmarks. C-^ flips between your last two buffers.
~/.config/emacs
This is the config you now have: one init.el you can read top to bottom, a dozen downloaded packages, and the same files on the laptop and the server.
Tick them off as you go. Your browser remembers the ticks; nothing else does.
0 of 8 done
A leader letter that matches an Emacs prefix is that prefix. Anything you read in the manual or online works with the leader too: swap C-h for SPC h, or C-x p for SPC p. In insert state, M-SPC is the leader.
| leader | same as | holds |
|---|---|---|
| SPC h | = C-h | help: describe keys, functions, variables, modes |
| SPC p | = C-x p | projects: switch, find file, grep, compile, magit |
| SPC r | = C-x r | bookmarks and registers |
| SPC w | = C-w | windows, the vim way |
| SPC x | = C-x | everything else Emacs keeps under C-x |
The other letters are your own groups:
SPC b buffersSPC c codeSPC d diredSPC e evalSPC f filesSPC g gitSPC m orgSPC s searchSPC t togglesSPC a todo.txt
Filter the way your minibuffer does: type words in any order. Try project file, bookmark or go.
No key matches all of those words. Drop one and try again.
SPC , and type part of a name. Start with b SPC, f SPC or m SPC to see only buffers, recent files or bookmarks. C-^ flips between your last two buffers.
SPC p p picks the repo. Then SPC p f finds files, SPC s r searches everything with ripgrep, SPC p c runs go test ./... with clickable errors, and SPC p m opens magit.
Completion pops up after two letters (C-n/C-p, RET). gd jumps to a definition and C-o comes back. K shows docs. SPC c a organizes imports, SPC c r renames, SPC c d lists errors. Saving runs gofmt.
Same keys as Go. jdtls 1.61.0 lives in ~/.local/share/jdtls and starts by itself when you open a .java file. It's the last release that runs on Java 21; 1.62.0 and later need Java 25.
SPC m c then s spark, i learned, p place or q queue. Each one is a single line at the top of life.org. SPC m l opens it, SPC m w opens today's entry in writing/2026.org.
SPC a opens todo.txt, the same file tuxedo edits. SPC g g shows the repo's status: s stages, c commits, P pushes, and each opens a small menu that shows the next key.
Ten goals, each building on the ones before. Every step uses a real key from your config. Unless a tutorial says otherwise, its steps were run in this setup before being written down.
tutorial 1 · about 15 minutes
Goal: a small package with a table-driven test. Watch it fail, jump straight to the failure, fix it, rename safely, commit.
First time only: tell git who you are. Without this, every commit in a new repo fails with unable to auto-detect email address.
git config --global user.name "Your Name" git config --global user.email you@example.com
Then make the module and open the first file:
mkdir -p ~/code/greet && cd ~/code/greet go mod init example.com/greet emacs greet.go
Press SPC g i, then RET. The folder is now a git repo, and that is what makes it a project for every SPC p key. q closes magit.
Press i and type the function. Completion pops up after fmt.Sp. Save with :w; gofmt tidies the spacing.
package greet
import "fmt"
// Greet says hello to name.
func Greet(name string) string {
return fmt.Sprintf("Hello, %s", name)
}SPC . and open greet_test.go. Write a test with two cases:
package greet
import "testing"
func TestGreet(t *testing.T) {
cases := []struct{ in, want string }{
{"Abed", "Hello, Abed!"},
{"", "Hello, stranger!"},
}
for _, c := range cases {
if got := Greet(c.in); got != c.want {
t.Errorf("Greet(%q) = %q, want %q", c.in, got, c.want)
}
}
}SPC p c, clear the suggested make -k with C-a C-k, type go test ./... and RET. Both cases fail, and each failure is a link. M-g n jumps to the first one in greet_test.go; press it again for the next.
Fix Greet, save, and press SPC p c then RET: it remembers the command. Inside the *compilation* window, gr reruns it too. You get ok example.com/greet.
func Greet(name string) string {
if name == "" {
name = "stranger"
}
return fmt.Sprintf("Hello, %s!", name)
}Put the cursor on Greet and press SPC c r, then type Hello. gopls renames it in both files, never touching strings that merely contain the word. gr on it lists every use; K shows its doc comment.
Commit: SPC g g, put the cursor on Untracked files and press s to stage them all, then c c. The message buffer opens in normal state, so press i, write the message, and finish with C-c C-c.
New keys: SPC g i SPC p c M-g n M-g p gr (rerun, in *compilation*) SPC c r gr (every use, in code) K SPC g g
tutorial 2 · about 20 minutes
Goal: compile and run a single file with a deliberate mistake, then move to a Maven project with tests, the way most real Java code is built.
Part A · a single file
mkdir -p ~/code/hello && cd ~/code/hello && git init emacs Hello.java
Type this, typo included. Within a few seconds jdtls starts, [eglot:hello] appears in the mode line, and nme gets underlined. SPC c d lists the errors in this file.
public class Hello {
public static void main(String[] args) {
String name = args.length > 0 ? args[0] : "Abed";
System.out.println("Hello, " + nme);
}
}SPC p c, clear the prompt, run javac Hello.java. The cannot find symbol error is a link: M-g n lands on line 4.
Fix it (cw on nme, type name), save, then SPC p c with java Hello.java World. Since Java 11 a single source file runs directly, with no separate compile step. You see Hello, World.
Part B · a Maven project
Maven isn't installed yet, so this half hasn't been run in your setup. These are the standard commands.
sdk install maven cd ~/code mvn archetype:generate -DgroupId=com.example -DartifactId=demo \ -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false cd demo && git init emacs src/main/java/com/example/App.java
jdtls reads pom.xml and fetches the dependencies the first time, which can take a minute; the mode line shows when it's busy. After that, completion knows your libraries too.
SPC p c with mvn -q test. Compiler errors appear as [ERROR] …/App.java:[12,5] … and are links, so M-g n works the same as with Go. To run one test class: mvn -q test -Dtest=AppTest.
On an error, SPC c a offers fixes such as adding an import or creating the missing method. SPC c r renames across classes.
gd works across your own classes. Jumping into JDK or library classes needs an extra package (jdtls serves them as jdt:// class files), which this config doesn't set up.
New keys: SPC c d SPC c a cw, plus everything from tutorial 1, which works the same way here.
tutorial 3 · about 10 minutes
Goal: move through an unfamiliar codebase by meaning instead of by scrolling. Start in the greet project from tutorial 1.
In greet.go, put the cursor on Sprintf and press gd. You are now inside Go's own source, fmt/print.go. C-o takes you back.
Go there again and press SPC s i: every function in the file, filtered as you type. Try Fprint.
Back in your project, on Hello press gr: every use, in a list. RET opens one. M-g n and M-g p walk the list without leaving your code.
SPC s r and type want: ripgrep across the whole project, previewing each hit as you move.
SPC w v splits the window. Then SPC p f opens greet_test.go on the right, SPC w h / SPC w l hop between the halves, and SPC w o goes back to one window.
Found a spot you'll need again? SPC r m and give it a name. SPC r b brings you back from anywhere, even after a restart.
SPC , then b SPC for open buffers only, or m SPC for bookmarks only. C-^ flips between your last two buffers.
New keys: gd C-o SPC s i gr M-g n SPC s r SPC w v SPC w o SPC r m SPC r b C-^
tutorial 4 · about 15 minutes
Goal: write your own command, try it while Emacs runs, give it a key under SPC i, and keep it in your config.
SPC b x opens *scratch*. Press i and type this. When you type (, Emacs adds the ); typing ) over it just steps past.
(defun my/insert-date (with-time)
"Insert today's date. With C-u, the time too."
(interactive "P")
(insert (format-time-string
(if with-time "%Y-%m-%d %H:%M" "%Y-%m-%d"))))ESC, cursor anywhere inside it, SPC e d. The echo area says my/insert-date: the command exists now.
Run it by name with SPC SPC my/insert-date. Then SPC h f my/insert-date shows your own docstring: Emacs documents your code like its own.
Give it a key while Emacs runs: type this line and press SPC e d on it.
(keymap-set my/leader-map "i d" #'my/insert-date)
In insert state, M-SPC i d types today's date and C-u M-SPC i d adds the time. (In normal state the text lands before the cursor, which is why insert state suits it.) This works at once because keymap-set changes the live map. Editing the big my/leader-map block in init.el builds a new map, and that's why those edits need a restart.
Keep it: SPC f c, find ;;; Leader key, paste the defun under my/sudo-this-file, and add this line inside my/leader-map:
"i" (cons "insert" (define-keymap "d" #'my/insert-date))
Restart Emacs. SPC now shows i as +insert.
Stretch: a command that copies the current file's path. Thanks to OSC 52 it reaches your laptop's clipboard even over SSH. Add it the same way, as "y" #'my/copy-file-path inside the "f" group, so it lives at SPC f y.
(defun my/copy-file-path () "Copy this buffer's file path, ready to paste anywhere." (interactive) (kill-new buffer-file-name) (message "Copied %s" buffer-file-name))
Commit and share it: SPC p p, pick the Emacs config, m, stage with s, c c, i and the message, C-c C-c, then P u to push. On the server, git pull.
Reading Lisp in five lines
(f a b) calls f with a and b. Code and data are both lists.(defun name (args) "doc" (interactive) body) makes a command you can bind to a key.(setq x 1) sets a variable; (let ((x 1)) …) makes one that only lives inside.tutorial 5 · about 15 minutes
Goal: make a sweeping change safely, review it piece by piece, and commit only what you mean.
Rename by meaning: SPC c r on a symbol in Go or Java renames it in every file. Comments and strings that happen to contain the word stay as they are.
Replace text across the project: SPC p r, type a regexp, then its replacement. At each match: y replaces, n skips, ! replaces the rest in this file, q stops.
Repeat an edit with a vim macro: qa, make the change on one line, finish with j0, then q. @a replays it once, @@ again, 10@a ten times.
Rename files the way you edit text: SPC d j, then C-x C-q. Edit the names (even :%s/old/new/ works), then C-c C-c applies, or C-c C-k cancels.
Review with SPC g g. TAB on a file opens its diff. s on one hunk stages only that hunk, and u unstages. For a few lines, select them with v, then s.
c c, i, write what changed and why, C-c C-c. P u pushes. Whatever you didn't stage stays in your working copy for the next commit.
New keys: SPC p r qa … q @a @@ C-x C-q TAB s u v c c P u
tutorial 6 · about 20 minutes
Goal: work on a branch, set unfinished work aside, merge it back and fix the conflict, all from magit's status buffer. Use the greet project from tutorial 1.
SPC g g. The status buffer is the hub: j/k move, TAB opens or closes a section, gr refreshes. Every letter opens a small menu that lists the next keys, so you can explore without memorising. SPC g SPC shows all of them.
New branch: b c, RET to start from where you are, and name it excited. The header now reads Head: excited.
In greet.go, change "Hello, %s!" to "Hey, %s!" and save. In magit, TAB on greet.go shows the diff, and s stages it. Then c c, i, the message, C-c C-c.
Set work aside: make another small edit, save, then z z and call it wip. Your working copy is clean again, and z p brings the edit back later.
Switch back: b b, pick master. Change the same line to "Hi, %s!" and commit it the same way.
Merge: m m, pick excited. Both branches changed the same line, so magit lists greet.go as unmerged.
RET on greet.go opens it with conflict markers. C-c ^ u keeps your side (the upper one), C-c ^ l takes theirs, and C-c ^ n jumps to the next conflict. Save.
Back in magit, move onto greet.go and press s. Then c c: the merge message is already written, so just C-c C-c.
History: l l shows the log as a graph, RET on a commit shows what it changed, and q goes back. In any file, SPC g b shows who last changed each line; q leaves.
Branching, committing, the merge and the conflict were run here. The z z name prompt, the log and blame weren't.
New keys: b c b b z z z p m m C-c ^ u C-c ^ l C-c ^ n l l SPC g b SPC g SPC
tutorial 7 · about 10 minutes
Goal: use a shell where commands, Lisp and Emacs buffers mix, and where cd can take you onto your server.
In a project, SPC p e opens Eshell at its root; anywhere else, SPC e s. RET runs the command in either vim state.
Ordinary commands work: ls, git status, go test ./.... The output is a normal buffer, so / searches it and y copies from it.
Lisp works at the same prompt: (* 6 7) prints 42. You can mix the two: echo (format-time-string "%A") prints today's weekday.
Send output into a buffer: ls *.go > #<buffer gofiles>. Then SPC , and gofiles shows it.
grep -n Hello *.go puts the results in a *grep* buffer where each hit is a link: RET or M-g n.
find-file go.mod opens a file in Emacs straight from the prompt.
M-p and M-n walk through the commands you ran before.
On your server: cd /ssh:HOST:~ and Eshell carries on over SSH. ls lists remote files, and find-file notes.txt edits one with your local Emacs. This part of Emacs is called TRAMP.
Steps 1 and 4 to 6 were run here. The echo mix, the history keys and the SSH step weren't.
New keys: SPC p e SPC e s M-p M-n, plus (lisp), > #<buffer …>, find-file and /ssh: paths
tutorial 8 · about 10 minutes
Goal: copy, move, rename and tidy files from the keyboard, the way a two-pane file manager works.
SPC d j opens the folder of the current file. j/k move, l opens, h goes up a folder.
+ makes a folder. Call it archive.
Mark files: m marks, u unmarks, U clears every mark, t flips them. %m marks by pattern: type \.go$ for every Go file.
Two panes: SPC w v splits, then open archive in the right pane. Back in the left one, C copies the marked files. Dired suggests the other pane as the destination, so RET is enough. r moves or renames the same way.
Delete: d flags a file and x deletes everything flagged; D deletes the marked files at once. Both ask first, and deleted files are gone for good, not moved to a trash folder.
Run a command on the marked files: X, then wc -l. Z compresses or uncompresses a file.
Search and replace inside the marked files: Q, the regexp, the replacement, then the same y / n / ! keys as SPC p r.
E opens a file with its system app, such as an image viewer or a PDF reader (Emacs 30, in a window).
These keys were checked against evil-collection's dired bindings, not run step by step.
New keys: + m u U t %m C r d x D X Z Q E
tutorial 9 · about 15 minutes
Goal: get comfortable with the Org basics behind life.org and writing/, in a practice file you delete afterwards.
SPC . and open ~/org/practice.org. A new Org file gets a title and date header by itself.
Type * Ideas and, below it, ** First one. TAB on a heading folds it; S-TAB cycles the whole file between an outline and everything.
A table: type | name | lang | and press TAB. Org lines it up and moves to the next cell. Fill a row, then |- and TAB draws a rule (so does SPC m b -).
A link: C-c C-l, type file:~/code/greet/greet.go or a web address, then a description. RET on the link follows it.
Make a heading a task with SPC m t (TODO, then NEXT, …). SPC m d t then RET inserts today's date.
Code that runs: <s TAB, write emacs-lisp after BEGIN_SRC, put (+ 1 2) inside, then C-c C-c inside the block. Org asks once, then writes the result, 3, under the block.
Capture without leaving your work: SPC m c s writes a spark at the top of life.org. C-c C-c saves it and takes you back; C-c C-k cancels.
Export: SPC m e, then h o writes an HTML page and opens it in your browser.
This follows standard Org behaviour and wasn't run step by step here.
New keys: S-TAB C-c C-l SPC m t SPC m d t C-c C-c C-c C-k SPC m e
tutorial 10 · about 10 minutes
Goal: add markdown-mode for README files the declarative way, configure it, keep both machines alike, and practise removing a package.
SPC f c, then under ;;; Packages add markdown-mode to the list. It comes from NonGNU ELPA, one of the release archives.
Give it a block, for example under ;;; Programming:
(use-package markdown-mode
:mode ("README\\.md\\'" . gfm-mode) ; GitHub-flavoured for READMEs
:custom (markdown-fontify-code-blocks-natively t))Restart Emacs. Startup notices the missing package and installs it. Open README.md: headings and code blocks are coloured now.
See what it added: SPC h m lists the keys of the current mode.
Commit and push (SPC p p, the config, m, …). On the server, git pull and restart Emacs: it installs the same package there.
Practise removing it: delete the name and the block, restart, then M-x package-autoremove. It offers to delete markdown-mode; answer y.
About once a month, M-x package-upgrade-all on both machines keeps them current and alike.
Not run here, since it downloads a package. The install-on-startup and autoremove behaviour it relies on was tested when this config was built.
New keys: SPC h m M-x package-autoremove M-x package-upgrade-all, plus :mode and :custom in a use-package block
Everything downloaded is one list near the top of init.el. Everything else ships with Emacs.
~/org/diary.init.el by its headings.( inserts ()./sudo:: and /ssh:host: paths, and a shell written in Lisp.Settings go in init.el. Commands you wrote yourself go in lisp/. What Emacs downloads or remembers stays out of git.
~/.config/emacs/ ├── early-init.el startup, frame look ├── init.el everything else ├── lisp/ │ ├── my-org-notes.el notes commands │ ├── my-todotxt.el todo.txt helpers │ └── which-keymap.el SPC h K ├── themes/ gruber-darker ├── docs/index.html this guide ├── README.md └── elpa/, history ... not in git
;; init.el after zM ;;; Packages... the download list ;;; Where things are... PATH, lisp/ ;;; Emacs itself... scratch, backups ;;; Evil... ;;; Leader key... every SPC binding ;;; Completion... ;;; Help... ;;; Files and projects... ;;; Git... ;;; Programming... eglot, go, folding ;;; Terminal... mouse, clipboard ;;; Org and notes... ;;; todo.txt... ;;; Look... theme, italics
;;; Packages and restart. Then give it a use-package block for its settings.:custom line in its block, put the cursor inside the block and press SPC e d. Restart when in doubt.my/leader-map under ;;; Leader key and restart Emacs. It starts in under a second.load-theme line.git pull on the server.The server runs Emacs 29.3. The same files work there; this exact setup was tested in an Ubuntu 24.04 container.
Get the config. The first start downloads the packages, which takes about a minute.
git clone git@github.com:alrawas/emacs-config.git ~/.config/emacs emacs -nw
Let copying in Emacs reach your laptop's clipboard through tmux. Add this to ~/.tmux.conf on the server. The second line gives tmux full colors from alacritty.
set -g set-clipboard on set -as terminal-features ',alacritty:RGB'
Only if emacs -nw says the terminal type alacritty is not defined: run this once from the laptop.
infocmp -x alacritty | ssh HOST -- tic -x -
Install the language server and ripgrep on the server too. go install doesn't care which folder you run it from: with @latest it builds the named version and puts it in ~/go/bin.
go install golang.org/x/tools/gopls@latest sudo apt install ripgrep
Java, on any machine with Java 21: install jdtls 1.61.0, the last release that runs on it (newer ones need Java 25), and put its launcher on your PATH. Add Maven or Gradle if your projects use them.
mkdir -p ~/.local/share/jdtls curl -L https://download.eclipse.org/jdtls/milestones/1.61.0/jdt-language-server-1.61.0-202609031315.tar.gz | tar -xz -C ~/.local/share/jdtls ln -s ~/.local/share/jdtls/bin/jdtls ~/.local/bin/jdtls sdk install maven
Two terminal habits: hold Shift while dragging to use the terminal's own selection, and start Emacs with emacsclient -t -a '' to keep one Emacs alive between SSH sessions.
/sudo::/etc/... path, or press SPC f U on an open file.~/.config/emacs/backups/ instead of ~/.Trash.*scratch*. There is no dashboard.org-capture-last-stored bookmarks.config.org is in git history, in the commit “Snapshot the literate config before the rewrite”.