Function: dired-do-find-regexp-and-replace

dired-do-find-regexp-and-replace is an autoloaded, interactive and byte-compiled function defined in dired-aux.el.gz.

Signature

(dired-do-find-regexp-and-replace FROM TO)

Documentation

Replace matches of FROM with TO, in all marked files.

As each match is found, the user must type a character saying what to do with it. Type SPC or y to replace the match, DEL or n to skip and go to the next match. For more directions, type C-h (help-command) at that time.

If no files are marked, use the file under point.

For any marked directory, matches in all of its files are replaced, recursively. However, files matching grep-find-ignored-files and subdirectories matching grep-find-ignored-directories are skipped in the marked directories.

REGEXP should use constructs supported by your local grep command.

Probably introduced at or before Emacs version 25.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/dired-aux.el.gz
;;;###autoload
(defun dired-do-find-regexp-and-replace (from to)
  "Replace matches of FROM with TO, in all marked files.

As each match is found, the user must type a character saying
what to do with it.  Type SPC or `y' to replace the match,
DEL or `n' to skip and go to the next match.  For more directions,
type \\[help-command] at that time.

If no files are marked, use the file under point.

For any marked directory, matches in all of its files are replaced,
recursively.  However, files matching `grep-find-ignored-files'
and subdirectories matching `grep-find-ignored-directories' are skipped
in the marked directories.

REGEXP should use constructs supported by your local `grep' command."
  (interactive
   (let ((common
          (query-replace-read-args
           "Query replace regexp in marked files" t t)))
     (list (nth 0 common) (nth 1 common))))
  (require 'xref)
  (defvar xref-show-xrefs-function)
  (defvar xref-auto-jump-to-first-xref)
  (with-current-buffer
      (let ((xref-show-xrefs-function
             ;; Some future-proofing (bug#44905).
             (custom--standard-value 'xref-show-xrefs-function))
            ;; Disable auto-jumping, it will mess up replacement logic.
            xref-auto-jump-to-first-xref)
        (dired-do-find-regexp from))
    (xref-query-replace-in-results from to)))