1.2 KiB
1.2 KiB
Replace text in multiple files using dired
Sometimes you may need to replace words or sentences across multiple files. That operation could be bore, since you will need to open, replace and close multiple files.
Emacs has options to deal with that situation using dired
. Let's say you need
to replace the word "code language" in multiple files within a directory.
You may follow this steps:
-
Open the directory using
dired
:- Use the keys1
C-x d
- Use the keys1
-
Mark all the files where you need to make the replacement
- You may press the key "m" over each name of the files
- Optionally press "t" to mark all files
- Then you may use
M-x
dired-do-find-and-replace
2 -
After this you will present with multiple occurrences of the text you will replace.
- You may replace all the occurrences using "!"
- You may also check every occurrence and use backspace to make a replacement by each occurrence