Emacs
A community for the timeless and infinitely powerful editor. Want to see what Emacs is capable of?!
Get Emacs
Rules
- Posts should be emacs related
- Be kind please
- Yes, we already know: Google results for "emacs" and "vi" link to each other. We good.
Emacs Resources
Emacs Tutorials
- Beginner’s Guide to Emacs
- Absolute Beginner's Guide to Emacs
- How to Learn Emacs: A Hand-drawn One-pager for Beginners
Useful Emacs configuration files and distributions
Quick pain-saver tip
my solution: switch to any non-ripgrep buffer and navigate with next-error
(defun bss/next-error-in-same-window ()
(interactive)
(let ((display-buffer-overriding-action '(display-buffer-same-window (inhibit-same-window . nil)))) (next-error)))
(defun bss/previous-error-in-same-window ()
(interactive)
(let ((display-buffer-overriding-action '(display-buffer-same-window (inhibit-same-window . nil)))) (previous-error)))
(global-set-key (kbd "s-[") 'bss/previous-error-in-same-window)
(global-set-key (kbd "s-]") 'bss/next-error-in-same-window)
Using M-x grep RET
with ripgrep
:
;; ripgrep as grep
(setq grep-command "rg -nS --no-heading "
grep-use-null-device nil)
Then M-g n
or M-g p
for the next/previous match. With (repeat-mode)
consequent next/previous are just n
and p
.
I use consult-ripgrep to do the search, which shows me a live preview of the match candidates. If I want to make a buffer with all the results, I call embark-act
then embark-export
to dump the results into a buffer.
I detail this workflow (including editing the matches!) here on my blog, which should have more details if you're lost.
Also try C-x p g
for a similar UI.
Customize xref-search-program
to make it use ripgrep under the covers.
Which points to the grep
command, so what really needs to be customize is grep-command
no?
I’m all about counsel or consult ripgrep, but deadgrep should get honorable mention too.
I have a shortcut for ivy-occur in the search result to make it into a proper buffer. With [g] I can refresh the search