Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

  > 1. Find and replace a pattern in a codebase with capture groups
  > git grep -l pattern | xargs gsed -ri 's|pat(tern)|\1s are birds|g'
Or, in IDEA, Ctrl-Shift-r, put "pat(tern)" in the first box and "$1s are birds" in the second box, Alt-a, boom. Infinitely easier to remember, and no chance of having to deal with any double escaping.


What you are doing here is to propose a very specialist approach ("Why not just use a SpaceX Merlin Engine, this is ?") when a slightly more cumbersome general approach ("This is how you get from A to B") was described.

IDEA is nice if you have IDEA.

"But not everyone uses Bash" - very correct (more fond of zsh, personally), but this article is specifically about Bash.


Yea, I've yet to come across a regex replacement tool as easy to use as jetbrains find & replace. Invaluable for certain tasks.


Using an IDE kind of handicaps you to only working with your IDE though. The shell works everywhere for every use case.


I've heard this many times, and I don't really understand the argument. I've used the shell plenty of times for this sort of work, but it's much more complicated to do certain things correctly than in an IDE. Things like looping over any filename, escaping arbitrary strings for use within sed patterns, xargs, multi-line replacements and regex lookahead require quite some in-depth knowledge, trial and error, and sometimes installing special tools because the defaults don't support the relevant patterns (like path NUL terminators or lookaheads). I don't have to deal with any of these in IDEA.


Of course it requires knowledge, but the point is that when you have that knowledge, it transfers to other things as well, making you far more capable in many more situations.


That particular IDE works on Windows though… no idea how to use Powershell…


WSL2?


From experience, WSL is pretty slow vs. native on fs operations.


For sure, but for the convenience of being able to use bash commands on Windows it's well worth it.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: