Search, change, inspect, repeat

0 of 1

The technique

Your textVim mode: Normal
Change the two current draft lines and keep the archive. Before: status: draft / next: draft / archive: draft. After: status: ready / next: ready / archive: draft.

Each . changes the next match. Stop before the archive: one more would change it too.

Keys in this lesson

cgn
Change the next search match; . changes the one after.
n
Next match.
.
Repeat the last change.

Before this lesson: Search reuse; repeatable changes.

More about this lesson

Keep exceptions while repeating a change to selected matches.

Search, make a change, use n to inspect the next match, then dot only where the same edit belongs. cgn includes selecting a search match in the change itself; dot can then seek and change the next match. Stop before exceptions. Neither a shorter route nor a successful dot proves that every match should change.

Example

If two current lines and an archive say pending, update the two current lines and leave the archive. Check each destination rather than blindly repeating across the file.

Use Reset to try again.

Guides on this topic

Exercise 1 of 1

0keys

par 17

Change both current draft values to final, preserving the archived value.

Your textVim mode: Normal

Desired result

const first = "final";
const second = "final";
const archive = "draft";

Yours

Par

Keyboard shortcuts
Ctrl+Enter
Check the result
Ctrl+Alt+U
Undo the last change
Ctrl+Alt+H
Show the next hint
Ctrl+Alt+R
Reset the exercise
Ctrl+Alt+P
Previous exercise
Ctrl+Alt+N
Next exercise
Enter
After a solve: the next step

Ctrl+Alt shortcuts leave Vim's own keys alone. On a Mac, Control and Option.