Emacs - Search and replacing versioned controled files
September 26, 2020 |
emacs
- Related pages
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:
M-x counsel-git-grep
Search for the string- Press
ivy-occur
key onivy
’s search prompt result, which is set toC-c C-o
by default. This will open the search results in a new buffer - On your new buffer, run
wgrep-change-to-wgrep-mode
(C-c C-p
) and do your editing. 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.