Tip 72 | Edit the Contents of a Macro |
In Tip 69, we saw that adding commands at the end of a macro is straightforward. But what if we want to remove the last command? Or change something at the beginning of the macro? In this tip, we’ll learn how to edit the content of a macro as if it were plain text.
The Problem: Nonstandard Formatting
Suppose that we’ve just followed the steps in Record One Unit of Work, saving our keystrokes into register a. Now we’re faced with this file, which is formatted slightly differently:
| 1. One |
| 2. Two |
| 3. three |
| 4. four |
Some of the lines already use a capital letter. In our macro, we used the ~ command, which toggles the case of the letter under the cursor (see ~ⓘ). Instead of using
Get Practical Vim, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.