emacs - Replace regexp / string / words in several / multiple files
To replace the same regexp, string or word in multiple files go into dired mode
C-x C-f RET
Then you should see a list of files.
Mark the files you want to edit with m.
To mark all files press t (M-x dired-toogle-marks).
You can also mark only all files but some: First mark the files which you don't want to be marked (by using m) and then press t.
All the other files get marked.
To mark files using a regular expression, e.g. to mark all .tex files you can use following key combination in dired mode
To replace a certain string or regular expression (regexp) in all marked files
Options during replacing:
- C-g (stopps the replacing)
- ! (replace the regexp string in the current file without asking)
- N (do no further replacements in this file)
- Y (replace all occurrences in all files, without asking)
Saving the modified buffers
C-u C-x s
This saves all modified files silently, i.e. without asking for confirmation.
M-x ibuffer *u (marks all modified buffers) S (capital 'S', saves all marked buffers) D (kills the marked buffers)