October 2015
Intermediate to advanced
356 pages
7h 54m
English
| Tip 68 | Repeat a Change on Contiguous Lines |
We can make light work out of repeating the same set of changes on a range of lines by recording a macro and then playing it back on each line. There are two ways to do this: executing the macro in series or in parallel.
As a demonstration, we’ll transform this snippet of text:
| | 1. one |
| | 2. two |
| | 3. three |
| | 4. four |
We’ll make it look like this:
| | 1) One |
| | 2) Two |
| | 3) Three |
| | 4) Four |
The task may look trivial, but it presents a couple of interesting challenges.
To begin, we record all changes made to the first line:
| Keystrokes | Buffer Contents | ||||
|---|---|---|---|---|---|
qa |
| ||||
0f. |
| ||||
r) |
| ||||
w~ |
| ||||
j |
| ||||
q |
|