Function: projectile-replace-regexp
projectile-replace-regexp is an autoloaded, interactive and
byte-compiled function defined in projectile.el.
Signature
(projectile-replace-regexp &optional ARG)
Documentation
Replace a regexp in the project using tags-query-replace.
With a prefix argument ARG prompts you for a directory on which to run the replacement.
Key Bindings
Source Code
;; Defined in ~/.emacs.d/elpa/projectile-20260310.858/projectile.el
;;;###autoload
(defun projectile-replace-regexp (&optional arg)
"Replace a regexp in the project using `tags-query-replace'.
With a prefix argument ARG prompts you for a directory on which
to run the replacement."
(interactive "P")
(let* ((directory (if arg
(file-name-as-directory
(read-directory-name "Replace regexp in directory: "))
(projectile-acquire-root)))
(old-text (read-string
(projectile-prepend-project-name "Replace regexp: ")
(projectile-symbol-or-selection-at-point)))
(new-text (read-string
(projectile-prepend-project-name
(format "Replace regexp %s with: " old-text))))
(files
;; We have to reject directories as a workaround to work with git submodules.
;; We also reject nonexistent files to avoid errors during replacement.
;;
;; We can't narrow the list of files with
;; `projectile-files-with-string' because those regexp tools
;; don't support Emacs regular expressions.
(seq-remove
(lambda (f) (or (file-directory-p f) (not (file-exists-p f))))
(mapcar #'(lambda (file) (expand-file-name file directory))
(projectile-dir-files directory)))))
(fileloop-initialize-replace old-text new-text files 'default)
(fileloop-continue)))