Like global search and replace but don’t like surprises?

Check out serpl – a handy little command-line app that gives you a visual preview of the changes you are about to make. You can even go in and remove the replacements you don’t want from the source previews. The regex support appears to be basic, however (I couldn’t get a negative lookbehind to work).

https://github.com/yassinebridi/serpl#readme

(Also, it appears they’re looking for maintainers. It’s written in Rust.)

#searchAndReplace #findAndReplace #CLI #app #serpl #dev

@aral for those of you using #Emacs it has a similar feature that can be run with M-x occur. You can also run the M-x multi-occur command to do find/replace across multiple files.

In an occur-mode buffer, you can press e to enter “edit mode” and modify each matching line in place, then press C-c C-c to commit those changes to the file. This allows you to do search/replace using the ordinary C-M-% command.

@ramin_hal9001 @aral Emacs has a number of modes that let you edit stuff in buffers, and then apply the changes, including wdired and wgrep.

@rpluim yes, I use wdired all the time.

It is much, much more safe and reliable than using tools like mv when renaming things. When I need to rename files in the terminal, I often use the command emacs -nw -Q . to open the current directory and edit the filenames like I would a file. Plus you have access to copy/paste and find/replace and all the other usual editing tools you might need available to you as you choose your file names.

Wgrep is also nice, but I don’t think it comes with the standard set of built-in tools for Emacs, I think you have to install that one separately. Multi-occur is built-in so I tend to use that one.

@aral