Emacs - Search and replacing versioned controled files

Emacs - Search and replacing versioned controled files

September 26, 2020 | emacs


I had to search and replace many files in a git repository, for some reason dired-do-find-regexp-and-replace, but I found using counsel-git-grep with wgre much easier. Here is on you do it:

  1. M-x counsel-git-grep Search for the string
  2. Press ivy-occur key on ivy’s search prompt result, which is set to C-c C-o by default. This will open the search results in a new buffer
  3. On your new buffer, run wgrep-change-to-wgrep-mode (C-c C-p) and do your editing.
  4. C-c C-c to apply your changes

I still have to figure out why isn’t dired-do-find-regexp-and-replace working properly on strings without any regular expression, for example name_to_change. It might be a bug on my end or upstream, but this might seem a bit related.


No notes link to this note

Go to random page