Hacker News new | ask | show | jobs
by haxney 2052 days ago
That only works if the identifier name is unique across your files. What if you have a field on class "Zoo" named "containers" and you want to replace it with "animal_containers", but only for the "Zoo" class? There are probably other usages of "containers" in the code, with no easy way for something like sed to distinguish between "zoo_instance.containers" and "car_instance.containers".

You need an editor that can understand "this usage of 'containers' refers only to class 'Zoo', so I should find all variables of type 'Zoo' which reference the 'containers' field and change those."

1 comments

> That only works if the identifier name is unique across your files

hence

> It's not precise, so it might take some manual work and tweaking with the patterns

and like I said,

> for how often I've had to rename identifiers, it works good enough to handle the bulk work.

so

> You need an editor that can understand

No I don't, because renaming across many files is rare enough that I don't need it.

Most of the time, I do refactoring before it's gotten out of hand and so regular vim features like I mentioned in another comment are typically enough.

In other words, I think such understanding by the editor is too much complexity (and language-constrained, at that) for little reward.