You could use iedit for that.
image source: iedit github repository
You should select your block of code and activate iedit-mode
(C-;
) to edit it.
When Iedit mode is turned on, all the occurrences of the current
region in the buffer (possibly narrowed) or a region are highlighted.
If one occurrence is modified, the change are propagated to all other
occurrences simultaneously.
If region is not active, ‘iedit-default-occurrence’ is called to get
an occurrence candidate, according to the thing at point. It might be
url, email address, markup tag or current symbol(or word).
In the above two situations, with digit prefix argument 0, only
occurrences in current function are matched. This is good for
renaming refactoring in programming.
After install iedit-mode
from MELPA, I encourage you to read the full help (C-h f
iedit-mode
).
query-replace
? What's the problem?