Live data from Hacker News

Show HN: Scooter – Interactive find and replace in the terminal

github.com

41–50 of 81 posts

Re: Show HN: Scooter – Interactive find and replace in the terminal

#41

[flagged]

Not affiliated, I just built a little tool to make my life easier and thought I'd share

It's great and clearly the community appreciates it! I'll put Show HN in the title since that's the convention for sharing one's projects on HN (https://news.ycombinator.com/showhn.html).

Btw, do you want to include some text giving the backstory of how you came to work on this, and explaining what's different about it? that's also the convention. If you post it in a reply to this comment, I'll move your text to the top of the thread.

Re: Show HN: Scooter – Interactive find and replace in the terminal

#43

Also see the excellent https://github.com/your-tools/ruplacer . For more advanced needs, I have a custom thing called greprep that let's you make changes using your favorite editor. Workflow is like this: 1. $ rg -n .... > /tmp/lines.txt 2. (edit lines.txt in vscode) 3. $ greprep /tmp/lines.txt to apply the changes

In Emacs, there is [helm-ag-edit](https://github.com/emacsorphanage/helm-ag) (but uses ripgrep if present). It's almost identical to your workflow, but all done inside the same app.

1. helm-ag # the search results are updated as you type 2. helm-ag-edit # edit the search result as regular text. Use multi-cursors, macros, whatever. 3. helm-ag-edit-save # commits the changes to the affected files

All those commands have keybindings, so it's pretty fast. I'll often open up Emacs just to do that and then go back to my JetBrains IDE.

Re: Show HN: Scooter – Interactive find and replace in the terminal

#44
You could also use vim in a loop. Say you want to replace "hello" in all files in the current dir with "world" and confirm every replace, then you would do:

    for f in $(grep -l 'hello' *); do vim -c ':%s/hello/world/gc | wq' "$f"; done
Or if you want to use some more vim magic, this simpler command will do the same:

    vim -c "argdo %s/hello/world/gce | update" -c "qall" *
"argdo" will do the replace command for each file, the additional e modifier in gce will ignore files that do not contain the search string and the second command "qall" is to quit vim after the work is done.

Re: Show HN: Scooter – Interactive find and replace in the terminal

#45
post #44

You could also use vim in a loop. Say you want to replace "hello" in all files in the current dir with "world" and confirm every replace, then you would do: for f in $(grep -l 'hello' *); do vim -c ':%s/hello/world/gc | wq' "$f"; done Or if you want to use some more vim magic, this simpler command will do the same: vim -c "argdo %s/hello/world/gce | update" -c "qall" * "argdo" will do the replace command for each fil…

[deleted]

Re: Show HN: Scooter – Interactive find and replace in the terminal

#48

Feels like we just keep making tools that already exist in Emacs.

I dunno, seems reasonable to me that we might have nice things without requiring everyone to use emacs. (And for those who do use emacs, I guess you're ahead of the curve?)
Post reply on HN