2023-10-20 Fizzbuzz Emacs Macro
Were you ever in dire need for the output of the Fizzbuzz[1] program
but couldn't be bothered to write/compile/run it again? Fret not,
with the following Emacs keyboard macros[2] you can generate the
sequence. No programming required.
; insert numbers 0-100
C-x r n a
C-x (
C-x r i a
RET
C-x r + a
C-x )
C-100 C-x e
; replace multiples of 3
M-<
C-x (
C-k
Fizz
C-a
C-3 C-n
C-x )
C-0 C-x e
; replace multiples of 5
M-<
C-x (
C-k
Buzz
C-a
C-5 C-n
C-x )
C-0 C-x e
; replace multiples of 15
M-<
C-x (
C-k
FizzBuzz
C-a
C-15 C-n
C-x )
C-0 C-x e
; tidy up
M-<
C-Shift BACKSPACE
Footnotes
~~~~~~~~
[1]
https://en.wikipedia.org/wiki/Fizz_buzz
[2]
https://www.gnu.org/software/emacs/manual/html_node/emacs/Keyboard-Macros.html