Note: A Vim macro that edits itself to draw a fractal

Nov 25, 2022

The text editor Vim is famous for its terse editing keyboard commands. It also features a “macro” mode where you can record these commands and reply them. Whats more, you can actually copy text from your editor and ask Vim to interpret the characters as a macro.

Linus Åkesson (who also created The Commodordion) took this to the extreme and created a text file that one can open in Vim, type the commands to copy and execute as a macro: GY@", and it will begin to edit itself into and ascii representation of the Mandelbrot set fractal!

The file:

From his page:

Note: If you have configured vim to use alternate keyboard mappings, these programs won't work. If this is the case, start vim with the standard mapping, i.e. "vim -u NONE mandelbrot".

See also, his interactive implementation of Towers of Hanoi using the same technique:

Update Aug. 18th, 2023: Only recently have I learned that this is the same guy who made the Commodordian.