This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-02-15
Channels
- # announcements (8)
- # architecture (9)
- # autochrome-github (1)
- # babashka (48)
- # beginners (55)
- # calva (36)
- # cider (16)
- # clj-commons (1)
- # clj-kondo (38)
- # cljs-dev (44)
- # cljsrn (1)
- # clojure (164)
- # clojure-europe (35)
- # clojure-nl (2)
- # clojure-norway (10)
- # clojure-uk (23)
- # clojurescript (50)
- # conjure (24)
- # core-async (1)
- # cryogen (2)
- # cursive (38)
- # datalevin (11)
- # datascript (2)
- # datomic (13)
- # duct (1)
- # emacs (16)
- # events (12)
- # exercism (3)
- # figwheel-main (7)
- # fulcro (26)
- # honeysql (5)
- # integrant (1)
- # jobs (3)
- # kaocha (6)
- # lsp (72)
- # malli (22)
- # nextjournal (35)
- # nrepl (1)
- # off-topic (34)
- # pathom (5)
- # polylith (8)
- # portal (40)
- # re-frame (14)
- # reagent (42)
- # reitit (1)
- # releases (1)
- # remote-jobs (1)
- # reveal (9)
- # sci (2)
- # shadow-cljs (13)
- # sql (3)
- # tools-deps (33)
- # vim (25)
What do you all use for "project-wide search and replace"?
I hacked something highly to my liking based on helm-ag
back in 2017 (which worked with ag
and rg
alike). However that only works in Emacs 25 (or 26 sometimes), which I managed to keep using quite flawlessly until these days - now it's much less of a viable option.
I reckon my requirements are simple:
• Search project-wide, ideally honoring rg
ignore rules or at least .gitignore
• Preview each found match as a single line in some sort of UI
• I can adjust my search query, and results/preview are updated real-time
• Replace all occurrences with an input that is asked interactively, after I got to see the preview of the found results
Ideas welcome!
deadgrep is awesome for "project-wide search", the replace part I still do manually 😄 Apparently it has https://github.com/Wilfred/deadgrep#beta-features (beta) which allows you to "edit files directly from results buffers" but I haven't tried it
you can do that with vertico (interactive list) + consult-git-grep (project wide search, with live preview) + embark (to export the list in new buffer) + wgrep (edit results in buffer)
helm-ag works fine for me, usually coupled with iedit when editing the changes that are found. I havent needed anything more https://practical.li/spacemacs/spacemacs-basics/evil-tools/replacing-text-across-projects.html
I have ripgrep binary installed, so can use its filtering patterns in the initial search https://practical.li/spacemacs/spacemacs-basics/working-with-projects/searching-projects.html
Thanks! from what I remember, with vanilla helm-ag too many steps were involved, hence my tweaking which IIRC halved the involved steps. I really appreciate a 'streamlined' workflow which I can eventually master by muscle memory, I guess I can use vanilla helm-ag again, and tweak again the bits that seemed redundant. Hacking from scratch sure is more effective than reverse-engineering whatever I did 5y ago :)
most of the modes from vertico author are really well done (consult, marginalia, corfu, etc), and they all compose nicely.

Nice! Do you have a search-and-replace wrapped under a defun or such? I'd be less enthusiastic about understanding/debugging each step from scratch
I just trigger consult-git-grep via a binding, the results show via vertico in the minibuffer, then once I am happy with the selection I trigger embark-export to get all the matches in a separate buffer via another binding and just edit the buffer contents, save, done
consult-git-grep + vertico is useful for other things, you can use that to navigate around, vertico will do a buffer preview as you go up/down the matches in the minibuffer
I use cousel-rg
+ ivy-occur
(setting ivy-calling
to t
when I want to preview each search result's file and also allows me to do mass edit)