Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Color replacements when using --replace #521

Closed
lydell opened this issue Jun 17, 2017 · 4 comments
Closed

Color replacements when using --replace #521

lydell opened this issue Jun 17, 2017 · 4 comments
Labels
enhancement An enhancement to the functionality of the software.

Comments

@lydell
Copy link

lydell commented Jun 17, 2017

ripgrep colors matches in red (by default). That's very useful.

When using the --replace option, I would find it very useful if the replacements were colored. Currently, nothing is colored (except file paths and line numbers of course).

Here's a screenshot showing what I mean:

screenshot from 2017-06-17 14-21-23

And here's a text sketch:

$ cat test
exponential notation: 123e4
another example: 42e-10
$ rg '(\d+)e' --replace '${1}E' test
1:exponential notation: <color>123E</color>4
2:another example: <color>42E</color>-10

What do you think?

(By the way, thank you very much for ripgrep. It's excellent.)

@BurntSushi BurntSushi added the enhancement An enhancement to the functionality of the software. label Jun 17, 2017
@BurntSushi
Copy link
Owner

Agreed. I like it!

@okdana
Copy link
Contributor

okdana commented Jun 19, 2017

Maybe a new colour spec? So you could do like --colors 'replace:fg:red' (with the default being identical to the default match spec)?

@BurntSushi
Copy link
Owner

@okdana I'd rather not add a new color spec. We should just use the existing match spec. When -r/--replace is used, all matches are replaced, so there's never a need to distinguish between the replacement color and the match color.

@okdana
Copy link
Contributor

okdana commented Jun 19, 2017

Fair.

I was thinking there would be some cases where you didn't want colouring, like when your replacement affects the entire line, but on balance an additional colour spec doesn't really help you there. If you ever have a situation like that where don't want the colours, you'll still have to pass --colors to disable them, and if you're doing that anyway you can just as well turn off match.

I retract my suggestion

jamessan added a commit to jamessan/ripgrep that referenced this issue Oct 7, 2017
BurntSushi pushed a commit that referenced this issue Oct 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement to the functionality of the software.
Projects
None yet
Development

No branches or pull requests

3 participants