*emacsgolf*

Every keystroke counts. Literally.

Given a start buffer and a target buffer, hole out in as few keystrokes as possible. Real Emacs, real keybindings, and a community of Emacsgolfers whose solutions will teach you tricks you didn't know Emacs had — one keystroke at a time.

holes17
golfers2
keystrokes recorded39

The holes

Transposition Trouble

Two pairs of words have swapped places overnight. Swap them back so the sentence reads as it should.

-UU-:**--  transpose-trouble1 golfer · best 6

Take a Number

Number each line: 1., 2., 3., and so on. Rectangle commands were invented for exactly this.

-UU-:**--  take-a-number1 golfer · best 22

The Great Reversal

Reverse the order of the lines: last line first, first line last.

-UU-:**--  great-reversal0 golfers · best —

Snake Charmer

This Python code is joining a JavaScript codebase. Rename every snake_case identifier to camelCase before code review.

-UU-:**--  snake-charmer0 golfers · best —

Order! Order!

These #include lines are in the wrong order. Sort them alphabetically before the linter notices.

-UU-:**--  order-order0 golfers · best —

No Comment

Delete every comment line. The code itself stays exactly where it is.

-UU-:**--  no-comment0 golfers · best —

The Ace

Re-wrap this one long line into a paragraph at most 70 columns wide. One perfect swing is enough.

-UU-:**--  the-ace1 golfer · best 1

Cut to Credits

The credits belong at the end of the film, not the start. Move the first line to the bottom.

-UU-:**--  cut-to-credits1 golfer · best 4

The Shouting

HR has asked for the printer memo again — this time in lowercase. Careful: stock Emacs ships some of its sharpest tools disabled.

-UU-:**--  the-shouting0 golfers · best —

Needle in a Haystack

One word in this text is misspelled. Search for it instead of scrolling — then swap the two letters that are out of order.

-UU-:**--  needle-in-haystack0 golfers · best —

Twin Cities

This list of cities has duplicates. Keep the first appearance of each city and delete the repeats.

-UU-:**--  twin-cities0 golfers · best —

Columns of Power

Delete the TEMP column from every line and close the gap. Rectangle commands were invented for this too.

-UU-:**--  columns-of-power0 golfers · best —

The Great Rename

Code review says tmp is not a name. Rename every occurrence to results — query-replace was born for this.

-UU-:**--  great-rename0 golfers · best —

Stoppage Time

Convert each minutes:seconds stamp to plain seconds — 05:16 is 316. A classic from the Vim-vs-Emacs wars (Vim’s best: 53 keystrokes); query-replace-regexp can do arithmetic.

-UU-:**--  stoppage-time0 golfers · best —

Military Time

The timestamps are 12-hour with a/p markers. Rewrite each as 24-hour hh:mm — 7:14a is 07:14, 3:47p is 15:47 — leaving the data alone. Afternoon costs +12.

-UU-:**--  military-time0 golfers · best —

Two for One

Every symbol pair is registered twice, once per direction. Collapse each mirrored pair of puthash calls into one xmsi-add-cycle. The original challenge was set in 29 keystrokes — beat it.

-UU-:**--  two-for-one0 golfers · best —

Separation Agreement

Split each defvar into a bare declaration and a separate setq holding the value. Structural sexp commands shine here.

-UU-:**--  separation-agreement0 golfers · best —

How to play

  1. 1 Get the client

    curl -O https://emacsgolf.com/emacsgolf.el

    then, in Emacs: (load "~/path/to/emacsgolf.el") — or drop it on your load-path and (require 'emacsgolf).

  2. 2 Claim your name

    M-x emacsgolf-register

    Pick a golfer name once; the server hands back a token that identifies your submissions from then on. Guard it like a favorite putter.

  3. 3 Pick a hole

    M-x emacsgolf

    Browse the course, hit RET on a hole. You get the start buffer on the left, the target on the right, and a running keystroke meter in the mode line.

  4. 4 Hole out

    C-c C-c

    when your buffer matches the target. Every keystroke from tee-off to C-c C-c counts — including M-x, minibuffer typing, and that C-g you'll regret. Submit, and enter the leaderboard.

Scores are verified by replaying your keystrokes in vanilla emacs -Q on the server — that's stock Emacs, so custom keybindings won't survive the replay (and neither, for now, do keyboard-macro definitions). Entries marked were accepted without replay. In-game keys: C-c C-c check & submit · C-c C-d diff against target · C-c C-r start over · C-c C-k quit the round.