Two functions in the same file share a throwaway name, tmp. The first
one is about to grow, so its tmp should become total — every
occurrence in that function, and none in the one below it, which keeps
its tmp.
A language server’s rename would do this across the project, but the build here has no rename, and the job is deliberately narrower than a project-wide rename anyway: one function, three occurrences. Helix gives you two ways to keep a change inside a boundary.
- Select the boundary first, then act inside it. Match mode’s text
objects (lesson 10) select a function body in one command; a line
selection extended over the function (lesson 5) does the same by hand.
Turn that one selection into a cursor on every
tmpinside it and nowhere else (lesson 11), then retype them all at once. - Or walk the matches with search (lesson 9), changing each and stopping when you reach the second function. Replaying the last change at each stop keeps it to a couple of keys per occurrence.
Either way, the outcome is what counts: make the buffer match the target under the editor.
One route, if you want it
With the cursor anywhere in total_price, mif selects the function
body. s, then tmp and Enter, leaves one cursor on each of the three
tmps inside that selection. c deletes all three and drops into insert mode; type
total and press Esc. The second function is untouched because it was
never inside the selection.