Checkpoint: repeat a change across a file
The technique
Search for the whole name, because cgn changes only what the search matched. Each . changes the next match.
Keys in this lesson
- .
- Repeat the last change.
- cgn
- Change the next search match. Then . changes the one after.
- qa
- Record a macro into register a. Press q to stop.
- @a
- Play macro a.
Before this lesson: The dot, cgn, Visual selection and macros.
More about this lesson
Make three or four changes in each of three real files, where most of them repeat.
You choose the commands here. When a change repeats, make it once in a way you can repeat, then use the dot, cgn or a macro for the rest. Watch for matches that should stay as they are. Help is still there if you need it, and your result notes whether you used it.
Example
Before you start, read the task and find every line that changes. Check the whole result when you're done.
Try without hints first. Open help if you need it.
Guides on this topic
Exercise 1 of 3
0keys
par 39The API takes the order's id now. Rename oid to orderId everywhere, send PATCH instead of PUT in both requests, and delete the comment about page size, which the API no longer has. You can use any commands.
Make it look like this
import { request } from "./client"; export function listOrders(page = 1) { return request(`/orders?page=${page}`); } export function getOrder(orderId) { return request(`/orders/${orderId}`); } export function renameOrder(orderId, name) { return request(`/orders/${orderId}`, { method: "PATCH", body: { name } }); } export function setDeliveryNote(orderId, note) { return request(`/orders/${orderId}/delivery`, { method: "PATCH", body: { note } }); }