Helm-grep project refactoring: search and replace

Table of Contents

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!

  1. 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))
  1. Then, execute helm-projectile-grep for the text you desire.
  2. Use C-x C-s to make permanent your search results to a buffer
  3. Use C-c C-p within that result buffer to execute wgrep-change-to-wgrep-mode and now you can make edits to any lines you please (including regular emacs search-and-replace commands)
  4. Use C-c C-c to save you changes, which will be promulgated to all files you’ve chosen to edit
Tory Anderson avatar
Tory Anderson
Web App Engineer, Digital Humanist, Researcher, Computer Psychologist