Tuesday, 02 June 2009
Emacs regexp replace in many files
- M-x find-dired
- Run find in directory: 'top directory to recurse'
- Run find (with args): -name *.[ch]
- A dired listing pops up
- Select/Mark all files, type: % m and press enter
- M-x dired-do-query-replace-regexp
- Query replace regexp in marked files: 'seach regexp'
- Query replace 'NNN' with: 'replacement text'
- You will now be prompted for each file with a math to do replace, just like you would a regual M-C-% search.
Note: regexp back references are allowed in the replacement text.
posted at: 14:44 | path: /emacs | permanent link to this entry