= Saving Vim Macros

To record a macro, press `q` in normal mode, followed by a paste registry to store the macro in. To define a quick macro to use a couple of times, I usually use the `q` registry, meaning I type `qq`. Vim will tell you you're currently recording a macro in the status line.

    --recording @q

Vim will now record your commands to be used later. For example, to convert a markdown-style link (`[Jeff Kreeftmeijer](https://jeffkreeftmeijer.com)`) to an asciidoc-style one (`https://jeffkreeftmeijer.com:[Jeff Kreeftmeijer]`) one, the recorded macro looks like this footnote:[A subsitution might be a better fit for this specific case]:

    f(di(F[Pa:^[f(xx

To use a defined macro again, press `@q` in normal mode.

To save a macro for reuse later, we can paste the contents of the `q` registry by pressing `"qp`, which produces the result above. We can then save our macro in our `~/.vimrc` file like this:

    let @q = 'f(di(F[Pa:^[f(xx'

Now Vim will remember the macro for the next time we accidentally use Markdown-style links in Asciidoc documents.