Hacker News new | ask | show | jobs
by modulus1 897 days ago
If you could pipe the ripgrep output into an editor, make changes, and have them applied, that would be great. Once you get all the text you want to change in one buffer, it should be easy to make repetitive changes quickly in your editor of choice.
1 comments

I think you can. You pipe to `vim`, and it will open a buffer with the contents. I am not sure if it will pipe out, though.

Edit: I've now tried it myself with `rep`.

It's not automatic, unfortunately. You can use `vipe` (part of moreutils on my machine) to pipe into vim (or any `$EDITOR`) and to pipe the result out.

However, `rep` wants a pager. If you run `vim` with `rep` at the end of the pipeline, everything gets garbled because `rep` (well, the pager) is the one taking key presses.

To get around this, you can pipe `rep` to something else. I piped it to `cat -`, which forced it into outputting to `stdout`.

So my final command looked like this:

    rg --no-heading --with-filename --line-number "\bstatic inline\b" include/ src/ tests/ \
        | vipe | rep inline y_cinline | cat -
Make sure your `$EDITOR` variable is set correctly for `vipe`.

Anyway, I'm going to add a PR to `rep` to add a command-line flag to output to stdout without a pipe. If it is accepted, that should help.