The most fun vim macro I've made solved a "solve this puzzle before we want to interview you" question. The problem was a URL to request that gave you a response to parse into the next URL, chained about 100 times. The vim macro took the URL in the current line, shelled out to make a network request for the result of `curl` with that line as an argument, and edited the result into the next URL to fetch.
Without macros, this traditionally involves a lot of copy-paste-change-stuff repetition.
With a Vim macro, I can happily just do this once, assign it to a register, and repeat as needed, and even store it for later reuse if I want.
There are also, littler things, like jumping between HTML tags, or bulk-indents.
What makes Vim's macros better (in my opinion) that other editor's macros is that fact that they're simply stored in copy-paste registers, meaning that you can have many of them, store in a different file, copy them off the internet, or compose them together.
For example, I may be testing a function and wanting to test a few scenarios on many IDs. So I will create a csv list of numbers and then use a macro to format it
your csv string will be like this (normally much longer)
134,234,367,4345
Then record the macro:
- type "myFunction("
- type ctrl + right arrow (this moves the cursor to after the comma)
- type backspace
- type ");"
- type enter key
then run stop recording and run the macro. It will produce:
myFunction(134);
myFunction(234);
myFunction(367);
myFunction(4345);
Which doesn't seem like a big time saver over regular copy and pasting. And you could have iterated over the csv string with a for loop. This is probably a really contrived and basic example but you find yourself thinking about using a macro anytime you have to do the same keystrokes over and over.
Compared to regex search and replace this is much more malleable, interactive, and ultimately powerful.
Although, there are still several situations where macros are better, especially things that involve several motions and edits. (I tend to use qw because w is more convenient to hit after @).
Also, it's occasionally useful to remember that you can use the double quote character " to paste a macro, edit it and then update it. i.e. ( "ep .... edit ... ^"ed$ )