October 2012
346 pages
7h 40m
English
| Tip 67 | 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:
| macros/consecutive-lines.txt | |
| | 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 |
|
Read now
Unlock full access