zhuang@linux:~/reading/practical-vim/11-macros/$ less

Practical Vim / chapter 11

Macros

$ grep tags 11-macros.md

This post extracts some knowledge from Practical Vim Chapter 11 – Macros.

The q key functions both as the “record” button and the “stop” button. To begin recording our keystrokes, we type q{register}, giving the address of the register where we want to save the macros.

The @{register} command executes the contents of the specified register. We can also use @@, which repeats the macro that was invoked most recently.

The golden rule is this: when recording a macro, ensure that every command is repeatable.

22 is a good number.

~ toggle character case.

qA qB to append commands to the end of Macro.

vim
:argdo normal @a

Execute the marco in all of the buffers in the argument list.

vim
:let i = 1
qa
I<C-r>=i<CR>) 
<Esc>
:let i += 1
q

We can edit the macro as plain text by pasting it into the document and back to the register.

zhuang@linux:~/reading/practical-vim/11-macros/$ comments