Skip to content

Instantly share code, notes, and snippets.

@d12frosted
Created February 27, 2016 12:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save d12frosted/9ceaa3999b42d95f21fd to your computer and use it in GitHub Desktop.
Save d12frosted/9ceaa3999b42d95f21fd to your computer and use it in GitHub Desktop.
A version of projectile-replace function that works with regexps. Be careful when using it on huge projects.
(defun projectile-replace-regexp ()
"Replace a string in the project using `tags-query-replace'.
Less efficient than `projectile-replace' but at least allows
usage of regular expressions. See
https://github.com/bbatsov/projectile/issues/576 for more details
on `projectile-replace' issue with regexps."
(interactive "P")
(let* ((old-text (read-string
(projectile-prepend-project-name "Replace: ")
(projectile-symbol-or-selection-at-point)))
(new-text (read-string
(projectile-prepend-project-name
(format "Replace %s with: " old-text))))
(files (-map (lambda (f) (concat (projectile-project-root) f)) (projectile-current-project-files))))
(tags-query-replace old-text new-text nil (cons 'list files))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment