Helm-grep project refactoring: search and replace
With this you can readily search an entire project directory for some text, and then make whole-scale changes to any or all files containing that text. I assume you already have helm-projectile installed and you use it; if not, you’re missing out!
- First, install wgrep and helm-wgrep, for which I use use-package and my emacs.el init file:
(use-package wgrep
:ensure t
:config (use-package wgrep-helm :ensure t))
- Then, execute
helm-projectile-grep
for the text you desire. - Use
C-x C-s
to make permanent your search results to a buffer - Use
C-c C-p
within that result buffer to executewgrep-change-to-wgrep-mode
and now you can make edits to any lines you please (including regular emacs search-and-replace commands) - Use
C-c C-c
to save you changes, which will be promulgated to all files you’ve chosen to edit