Find and Replace
I hate using sed and xargs in tandem with find for doing mass replacements. There are multiple approaches one can take, the simplest being
find . -type f -exec sed -i 's/<find>/<replace>/g' {} +
However remembering this syntax and all its idosyncracies is annoying. So I was on the lookout for emacs native ways of approaching the same.
The first being using M-x rgrep:
- Enter the search term
- Then limit the search to files if needed
- It presents you with a
*grep*buffer - Use
M-x grep-chage-to-grep-edit-modeto make the grep buffer editable M-x replace-regexpto perform the find and replace
This modifies all the buffers but doesn’t save them, you can switch to ibuffer:
- Type
* uto mark all unsaved files - Save them all using
S - Close them using
D