Hacker News new | ask | show | jobs
by pyoung 3408 days ago
How often do you find yourself doing operations like this? I feel like it would take me more time to formulate and confirm that your set of commands are correct than it would for me to just ctrl+f to each instance and then ctrl-v the ones that needed to be changed. Don't get me wrong, I think it is really cool that you can do this, but it feels like this requires a level of fu that is beyond most typical programmers.
1 comments

you search and replace by hand?

... are you serious?

Thanks for the substantive reply;)

In almost all cases where I need to do a find/replace there are typically no more than 4-5 references that need to be updated. And I think a better way to phrase my behavior is I search, inspect the code to make sure that my change won't introduce a bug or some unintended consequence, and then replace. This may be slower, but in the grand scheme of things it barely registers on my overall productivity and if it saves even one bug from getting introduced into the code than the extra time spent probably pays for itself. If I need to update more than just a handful of references, than Sublime has a perfectly functional find/replace tool, but I have only ever really needed it maybe 3-4 times in the last few years.

To get back to the question at hand. How long does it take you to formulate these series of commands in your example? Because to me it feels like it would take longer to come up with a correct set of commands for your example than it would be to just search and replace 'by hand'. Of course if you are updating 100's of references than spending some extra time to formulate your solution makes sense, but in your example, you limited your search ~1000 loc, so presumably you are only updating a few lines, maybe a dozen at most? I understand that vim is powerful tool, but it seems to solve problems that I don't have (or that I don't consider to be problems), and I am genuinely curious as to the sort of problems and types of code bases that vim aficionados work on.