←back to thread

131 points tomschafer | 1 comments | | HN request time: 0.001s | source
Show context
CGamesPlay ◴[] No.42152656[source]
Since we're all giving replacements to this, nobody's mentioned my preferred one, so: use git add's patch mode. On a clean worktree, do the search/replace in bulk. Then use `git add --patch` to selectively add the good replacements and skip the bad ones. Finally, `git checkout -- .` to throw away all the bad ones. The nice part about this is that it's not much to remember. If you can make a global search and replace, and you can use `git add --patch` (which is useful loads of times), you can do a selective search and replace by combining them.

As far as this actual tool: the demo GIF is way too fast-paced to show what's going on. A better demo would maybe search "ring", have 10 or so results instead of pages and pages, and show how you can unselect "spring" matches which were unintentionally caught.

replies(3): >>42156267 #>>42160088 #>>42164463 #
1. augusto-moura ◴[] No.42160088[source]
Pretty neat trick, I will definitely use it in the future

But it only works in git repositories. Sometimes you need to search and replace on non-git repositories, for those cases Scooter might be the answer