Why
Ripgrep is a fast search tool like grep
. It's mostly a drop-in replacement for ag
, also know as the Silver Searcher.
helm-ag
is a fantastic package for Emacs that allows you to display search results in a buffer.
You can also jump to locations of matches. Despite the name, helm-ag
works with ripgrep (rg
) as well
as with ag
.
How
-
Install ripgrep
-
Make Spacemacs use helm-project-do-ag directly when pressing
SPC /
without preselecting the symbol under the cursor.Type
SPC f e d
to bring up~/.spacemacs
.(defun dotspacemacs/user-config () ;; .... (evil-leader/set-key "/" 'spacemacs/helm-project-do-ag))
-
Force ripgrep as search tool
SPC SPC customize-set-variable
Select variable
helm-ag-base-command
Set value to
rg --vimgrep --no-heading --smart-case
Usage
SPC /
should allow you to search in the current project.
You can prefix patterns with options
-G*.cljs -w time
- search for the word "time" in all .cljs
files
-tclojure time
- search for "time" in all .{clj,cljs,cljc}
files
uno\ due\ tre
- search for the string "uno duo tre"
-C5 foo
- search for "foo" but show 5 lines of context before and after the match
(?:^|[^\w-])time(?:[^\w-]|$)
- search for lisp-word "time", i.e. search for the full word "time"
while considering "-" to be a word characer
Hi there, 👋
Thanks for sharing this info (I really appreciate it). So, I was trying to set this up by myself but, as a brand new to spacemacs (and lisp) I'm still struggling hard with all those things in the
.spacemacs
file (This is my 2nd day with spacemacs/emacs). Hope any of you can give me a hand.later, when I run
SPC SPC customize-set-variable
and search forhelm-ag-base-command
, it doesn't exist (should it exist?).Could you point me what I'm doing wrong? Thanks in advance for your help! 🙏
Info-Versions