Using Emacs to recursively find and replace in text files not already open?

M-x find-name-dired: you will be prompted for a root directory and a filename pattern. Press t to "toggle mark" for all files found. Press Q for "Query-Replace in Files...": you will be prompted for query/substitution regexps.

Proceed as with query-replace-regexp: SPACE to replace and move to next match, n to skip a match, etc.

Otherwise it's a great option for a single directory. – Blair Conrad Nov 7 '08 at 3:55 7 No, it's recursive. The non-recursive version would be %m in dired-mode.

– Chris Conway Nov 7 '08 at 13:26 1 This is probably a problem with the emacs/find configuration, possibly related to archivum. Info/bug-gnu-emacs@gnu.org/2005-10/msg00120.html What's the text of the error? – Chris Conway Nov 8 '08 at 19:49 1 find .

"(" -iname "test. C" ")" -exec ls -ld "{}" ";" Access denied - . File not found - -INAME File not found - TEST.

C File not found - ) File not found - -EXEC File not found - LS File not found - -LD File not found - {} File not found - ; – Rob Kam Nov 8 '08 at 23:14 1 Steen, Chris: Probably not exactly what you want but you can use 'C-x s' (save-some-buffers), it will prompt you for each modified file, so you only have to hit 'y' multiple times. – danielpoe Jun 3 '09 at 13:17.

I generally use other tools to perform this task, and it seems like many of the approaches mentioned at EmacsWiki's Find and Replace Across Files entry shell out, but the Findr Package looks very promising. Stealing part of the source file: (defun findr-query-replace (from to name dir) "Do `query-replace-regexp' of FROM with TO, on each file found by findr.

Using dired to recurse down a deep directory tree is going to be a bit slow for this task. You might consider using tags-query-replace. This does mean shelling out to create a tags table, but that is often useful anyway, and it's quick.

Interactively Find and Replace String Patterns on Multiple Files might explain what you ask. Still, it uses find, so it's not exactly what you want.

Try Icicles search. You can replace on demand while searching. No need to y/n each search hit in turn -- access only the hits you want, in any order, replacing as needed.

You can even sort the search hits for easier access/navigation. And search is over search contexts that you define -- you don't necessarily need to search all of the text in the files (e.g. Skip comments). A simple example of a search context is a line, as in grep, but a context can be anything you like.

M-x find-name-dired RET it may take some time for all the files to appear in the list, scroll to bottom (M->) until "find finished" appears to make sure they all have loaded Press t to "toggle mark" for all files found Press Q for "Query-Replace in Files...": you will be prompted for query/substitution regexps. Proceed as with query-replace-regexp: SPACE or y to replace and move to next match, n to skip a match, etc. Type! To replace all occurrences in current file without asking, N to skip all possible replacement for rest of the current file.

(N is emacs 23 only) To do the replacement on all files without further asking, type Y. Call “ibuffer” (C-x C-b if bound to ibuffer, or M-x ibuffer RET) to list all opened files. Type * you to mark all unsaved files, type S to save all marked files * * RET to unmark all marks, or type D to close all marked files This answer is combined from this answer, from this site, and from my own notes.

Using Emacs 23.

1 ibuffer is not bound to C-x C-b by default. – phils Nov 5 '11 at 3:20 @phils - Any suggestions? – Ballpark Nov 15 '11 at 22:19 Well personally I recommend that people do bind C-x C-b to ibuffer, because it's so much better than the default binding.

Just add (global-set-key (kbd "C-x C-b") 'ibuffer) to your . Emacs file. Failing that, use M-x ibuffer RET in the above instructions.

– phils Nov 15 '11 at 22:47 ok. I think I have the emacs startup kit, which is why mine is bound – Ballpark Nov 15 '11 at 23:07.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions