💾 Archived View for g.codelearn.me › 2023-04-11-emacs-wgrep.gmi captured on 2024-08-18 at 17:23:00. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2023-04-19)

-=-=-=-=-=-=-

Emacs & Wgrep

So I just discovered `wgrep` mode of a grep buffer in Emacs and it's incredible.

I often use `projectile-ripgrep` if I need to find something in the project I'm working on. But if I wanted to rename some variables or strings that I grepped I had to go and manually update them or use something like `projectile-replace`.

But turns out there is `wgrep` mode that is available from `projectile-ripgrep` (`*rg*`) buffer or from `*grep*` buffer.

In case of you `ripgrep` you just press letter `e` and now you can edit anything you want. Then you press `C-x C-s` and now all the changes are made. Amazing.

Here is an example. Let's try to find and replace `projectile-` string in this blog:

Here is what was found (image is clickable)

now I press `e` and I can edit the buffer. It says this in the message area:

Now I changed few occurrences of the `projectile-` to `project-` and pressed `C-x C-s` and now those two files are edited without me even visiting them.

You can save all unsaved buffers with `C-x s`

Incredible discovery. I'm going to use it all the time now.

I'm not sure though what kind of feature is this. It's not a package that I had to install. It's just there and it works.