back

by guytv·5y ago·view on hn ↗
Could you explain how would you go about renaming a method with a few dozen usages using VIM? (curious what's the "right" way to do this in Vim)
2 comments
I spent a bit more than half of my professional career developing in Perl, on a large web application implemented across 100+ modules. All of my work was done through a terminal connected to a remote server, using vim.

When I had to rename something, it was a manual process: one terminal opened to the command line, using grep to locate all of the instances I might want to rename. From there I could use sed or perl on the command line to do the renaming, or I could open individual files in vim. Once in vim, I could use a global search and replace command, or search for each instance and replace manually or with a macro or . command.

Slower than an IDE? Absolutely. But it never changed something I didn't intend to change, and the process taught me the value of good naming conventions. I never felt it was a hassle, and I became very good at refactoring without breaking things.

Today, I use Visual Studio to develop in C#, Javascript, and sometimes Typescript. The C# refactoring tools are great, and I've learned to trust them, though my naming convention habits are still useful when it comes to refactoring names in comments. Javascript, and to a large extent Typescript, generally require my old manual search and replace process. And whenever I do any refactoring, I always have a separate commit for it, which I carefully review to make sure the tools didn't do anything unexpected.

If they’re using a language server plugin, it’s entirely possible that they just call a refactor function provided by the LS. This works just as well in vim or emacs as it does in vscode, since they can all use the same language servers (generally)