How do I record a macro that uppercases a word and advances so I can replay it across words?
Answer
qagUiwWq2@a
Explanation
Macros are most powerful when they encode both the edit and the movement to the next target. qagUiwWq2@a is a compact pattern for that: you record one transformation, then replay it across subsequent words without rethinking navigation.
How it works
qastarts recording into registeragUiwuppercases the inner word under the cursorWjumps to the start of the next WORD, preparing the next replay targetqstops recording2@areplays the macro two more times
Because the movement is built into the macro, each replay lands in the correct place automatically. This is much more reliable than manually moving between runs, and it scales to larger batches with a bigger count (10@a, for example).
Example
Before:
alpha beta gamma delta
Run:
qagUiwWq2@a
After:
ALPHA BETA GAMMA delta
Tips
- If a macro should continue until failure, you can use a high replay count and let motion failure stop it
- Keep the macro idempotent when possible so accidental extra runs are easy to recover from