Ever since I read Abo-abo’s post on using wgrep to edit multiple files, I’ve been a huge fan of using grep to search for some regular expression in multiple file, write enable the results buffer with wgrep, make changes to the results, and save those changes back to the original files. Although there are multiple workflows to accomplish this. they all involve using one of the grep commands to search for the regexp in multiple files, modifying the grep results, and then saving the results back to the files. This is an extraordinarily powerful technique that’s easy to generalize.
Tony Aldon has a post that offers another variation on the theme. It’s basically the same except that he uses rg.el to perform the grep duties. It’s very similar to what I do except that I use counsel-rg (part of the ivy swiper package) to do the searching.
Regardless of the details, the grep/wgrep paradigm is a powerful one and definitely worth knowing. It can make a complex refactoring utterly simple. The takeaway from all the posts on the matter is that you can use whatever flavor of grep you like and just write enable the grep results buffer to make changes that are reflected back to the original files.