(no title)
bastijn | 1 year ago
First one for instance with resharper plugin enabled or in any IntelliJ IDE: Ctrl R R, type new word. Bonus; replaces all instances of the variable and recognizes scope in the file so if you have two locals with the same name over two methods it would change only the one you want. You want all, multi-carrot expansion Ctrl D D until you hit what you want and replace. Multi Carret is so powerful, find a repeating pattern, can be anything and even if it occurs further down where you don’t want to change just stop hitting expansion. Sure, you can do the same with VIM but comparing VIM to modern refactoring plugins is way more fair.
Things like extract method, extract variable and replace all instances at once are also one keybind away.
denvaar|1 year ago
Repulsion9513|1 year ago
jauntywundrkind|1 year ago
That said, many of these refactor systems are multi-file capable. Or even more fancy, they understand for example that an export is being renamed & update all consumers, leaving all other uses of that variable name as-is.
I'm a pretty mediocre but long time vim user. I don't intend to leave. But I remain interested in codemod tools that can help me reshape code at scale.
lawn|1 year ago
You get context aware search and replace with LSP in Vim too.
camgunz|1 year ago
%s/thingamabob/doodad/g
You can put regexes in there, so for 99% of cases you're fine. In neovim (but not in vim) this will also show you a "multicaret" UI.
This is also just one mode of sed, so if you need to do this across multiple files you can just run sed.
lambdaba|1 year ago
t43562|1 year ago