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 I guess you just have to reinvent emacs but in a way that they are not easily interlope-able...

I guess you just have to reinvent emacs but in a way that they are not easily interlope-able

@tusharhero what are you talking about?! You can use Unix pipes to make everything interoperable!!! (Sarcasm)

@aral

@ramin_hal9001 @aral That might be true for some programs. But most programs (TUI) are not at all designed for that.

Vim, for example, is not at all like that. I don't know if you can at least pipe buffer regions into programs or not, probably can. But that is something I do all the time inside Emacs.

(I know you are joking).

@tusharhero yes, you gleaned the point I was making exactly.

Terminal apps are basically like cell phone apps, where there is no attempt (beyond copy-paste, or simple message passing, like what Android OS calls “intents”) to make programs interoperable at all, because there is basically no infrastructure for it. I mean, sockets exist on most operating systems, but this just forces you to isolate functionality into a client-server architecture with well-defined protocols (DBus, for example), and a lot of these TUI app never even bother with such things. They are just GUIs that use ANSI terminal codes to draw things on screen.

They all operate in isolation, they all have their own unique command line syntax, their own unique configuration scripting syntax, their own unique user interface, you have to relearn everything for each TUI tool you decide to use.

To be fair, Lisp languages (e.g. Emacs) can be just as chaotic, but there is at least more of an attempt to unify all the disparate apps under a single configuration language and UI/UX philosophy. Everything can be scripted using the same, well-defined, turing-complete programming language, and messages are passed between apps using a well-structured and consistent protocol (S-expressions) that is built-in to the system itself.

@aral

@tusharhero @ramin_hal9001 @aral You definitely can pipe regions of a vim buffer to a command. I'd say it's even encouraged among vim users.