Skip to content
Tutorials Center
My learning

Topics

Lesson 37 of 38 ยท Projects and Practice

Practice: Emacs Key Drills, Key Notation and Self-Testing

Build muscle memory with graded Emacs drills for movement, editing, windows and buffers, learn the key notation used in docs and kbd strings, and quiz yourself.

Emacs is learned with your fingers. Reading about C-x C-f helps once; pressing it fifty times makes it automatic. This practice lesson gives you graded drills, explains the key notation you meet in manuals and configuration (C-M-<return>, s-<left>, kbd strings), and includes small programs that parse that notation and run a spaced flash-card quiz.

The drills are real Emacs key sequences. The runnable programs are JavaScript stand-ins.

Key notation

Documentation writes keys in a compact notation. Read it like this:

Notation Meaning
C-x hold Control and press x
M-x hold Meta (Alt, or ESC then x) and press x
S- Shift, s- Super (the Windows or Command key), H- Hyper
C-M-f Control and Meta together, then f
C-x C-f two keys in sequence: Control-x, then Control-f
<f5>, <return>, <up> function and named keys (in angle brackets)
RET, SPC, TAB, ESC, DEL return, space, tab, escape, backspace
C-x 4 C-f a sequence mixing plain and Control keys: Control-x, then 4, then Control-f

kbd and keymap-set use the same notation in strings: (keymap-set global-map "C-c m" #'my/cmd), (kbd "C-x C-s"). Use C-h k followed by a key to see its description, and C-h l (view-lossage) to see the last 300 keys you pressed.

JS Stand-in: parse key descriptions

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Drill set 1: moving

Open any text file (or the *scratch* buffer after pasting some text). Practise each for a minute, then repeat without looking.

  1. Character and line: C-f, C-b, C-n, C-p; line ends C-a, C-e, and M-m to the first non-blank character.
  2. Words: M-f, M-b; delete a word with M-d (forward) and M-DEL (backward).
  3. Sentences and paragraphs: M-a, M-e, M-{, M-}.
  4. Screen: C-v, M-v, C-l (centre the cursor line), M-< and M-> for start and end of buffer.
  5. Jumps: M-g g 40 RET (go to line 40), C-s then text (search), C-r backwards, C-u C-SPC back to previous positions.

Goal: move to any word in a paragraph in at most four keys without arrow keys or the mouse.

Drill set 2: editing

  1. Kill and yank: C-k (kill line), C-w (kill region), M-w (copy), C-y (paste), then M-y to cycle older kills.
  2. Region: C-SPC set mark, move, then act; C-x h selects everything; M-h the paragraph.
  3. Undo: C-/ or C-_ undo; C-g aborts anything; C-? or C-M-_ redo (Emacs 28+).
  4. Transpose: C-t letters, M-t words, C-x C-t lines; M-c, M-u, M-l change case.
  5. Rectangles and macros: C-x SPC then C-x r t to add a prefix to ten lines; F3 ... F4 and C-u 10 F4.
  6. M-% (query-replace) with y, n, !, q.

Drill set 3: buffers, windows, files

  1. C-x C-f open, C-x C-s save, C-x C-w save as, C-x b switch buffer, C-x k kill buffer, C-x C-b list buffers.
  2. C-x 2 split below, C-x 3 split right, C-x o other window, C-x 1 only this window, C-x 0 close this window.
  3. C-x 4 C-f open file in another window; C-x d Dired; C-x C-j Dired from the current file.
  4. C-h t (the built-in tutorial), C-h k, C-h f, C-h v, C-h m (describe the current modes).

Goal: open two files side by side, copy a paragraph from one to the other and save both, using only the keyboard, in under a minute.

Spaced self-testing

Make flash cards of the keys you miss: a prompt on one side, the keys on the other. The program below uses a simple Leitner box rule: a correct answer moves a card to a longer review interval, a wrong answer sends it back to box 1.

JS Stand-in: a spaced-repetition quiz

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Exercises to do in Emacs

  1. In *scratch*, evaluate (+ 1 2) with C-j. Then define a function with defun and call it.
  2. Open the Emacs tutorial with C-h t and finish it; note three keys you did not know.
  3. Customize one option with M-x customize-variable, then copy it into init.el as setopt.
  4. Record a macro that turns a list of names into a Markdown bullet list, then run it on 20 lines.
  5. Use Dired to rename ten files with C-x C-q; then try % m to mark by a pattern.
  6. Open a Git project with C-x g, stage one hunk, commit with a good message.
  7. Use M-x compile with a command that fails, then step through errors with M-g n.

Do not try to learn everything at once. Pick three new keys a day, put a sticky note on the monitor, and use C-h l at the end of the day to see what you actually pressed. The keys you reach for repeatedly will move into your fingers.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. In key notation, what does C-M-f mean?

    Modifiers joined by hyphens apply to the same key press.
  2. 2. Which command shows the last keys you pressed?

    view-lossage lists recent key presses and commands, useful when something unexpected happened.
  3. 3. How do you close every window except the current one?

    C-x 1 deletes other windows; C-x 0 closes only the current one.
  4. 4. In the Leitner method, what happens to a card you answer wrongly?

    Missed cards go back to the shortest interval so you see them again soon.

Summary

  • Key notation: C- Control, M- Meta, s- Super, <f5> named keys, RET/SPC/TAB; kbd uses the same strings.
  • Drill movement, editing, and window/buffer commands in short daily sessions.
  • C-h k, C-h l, C-h t teach you what a key does and what you pressed.
  • Use spaced repetition for keys you forget.
  • Finish with real tasks: macros, Dired renames, Magit commits, compile loops.

Next: Troubleshooting and Performance