-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
trim whitespace from lines #917
Comments
This is an interesting request. I'm not sure if it's a fit. What would you use it for? I see your example, but indentation is often a useful artifact to see in the output. Is it just an aesthetic thing? |
@BurntSushi Thanks for such a quick response. Actually, yes, just an aesthetic thing. Personally, when grepping code, I don't find the indentation interesting: if I later need to edit the file, I already know the line to go to; and if I just need to read the output, because of the lacking context, as we just get the single line, the indentation doesn't actually help in many cases, IMHO. |
@julenpardo Interesting. So if this flag were added, would you just have it always enabled? How would you use it? |
For whatever it's worth, this is a feature that interests me too, and if you decide that it's a good idea i'd be willing to work on it. I mentioned in #544 that i used to have a wrapper script for If the feature were added, i would put |
@BurntSushi I was thinking about adding it as a non-default option and then adding it to my ripgrep config file. I mean, I wouldn't make as default such a significant visual change in the output just because it came to my mind :) |
@julenpardo Oh, no, yeah, this definitely can't be enabled by default. What I meant is whether you would enable it by default. :-) In any case, I think you and @okdana sold me. I see two ways this can get added:
|
I am working on the new printer right now, and I should be able to add this in with very little fuss. |
This commit updates the CHANGELOG to reflect all the work done to make libripgrep a reality. * Closes #162 (libripgrep) * Closes #176 (multiline search) * Closes #188 (opt-in PCRE2 support) * Closes #244 (JSON output) * Closes #416 (Windows CRLF support) * Closes #917 (trim prefix whitespace) * Closes #993 (add --null-data flag) * Closes #997 (--passthru works with --replace) * Fixes #2 (memory maps and context handling work) * Fixes #200 (ripgrep stops when pipe is closed) * Fixes #389 (more intuitive `-w/--word-regexp`) * Fixes #643 (detection of stdin on Windows is better) * Fixes #441, Fixes #690, Fixes #980 (empty matching lines are weird) * Fixes #764 (coalesce color escapes) * Fixes #922 (memory maps failing is no big deal) * Fixes #937 (color escapes no longer used for empty matches) * Fixes #940 (--passthru does not impact exit status) * Fixes #1013 (show runtime CPU features in --version output)
This commit updates the CHANGELOG to reflect all the work done to make libripgrep a reality. * Closes #162 (libripgrep) * Closes #176 (multiline search) * Closes #188 (opt-in PCRE2 support) * Closes #244 (JSON output) * Closes #416 (Windows CRLF support) * Closes #917 (trim prefix whitespace) * Closes #993 (add --null-data flag) * Closes #997 (--passthru works with --replace) * Fixes #2 (memory maps and context handling work) * Fixes #200 (ripgrep stops when pipe is closed) * Fixes #389 (more intuitive `-w/--word-regexp`) * Fixes #643 (detection of stdin on Windows is better) * Fixes #441, Fixes #690, Fixes #980 (empty matching lines are weird) * Fixes #764 (coalesce color escapes) * Fixes #922 (memory maps failing is no big deal) * Fixes #937 (color escapes no longer used for empty matches) * Fixes #940 (--passthru does not impact exit status) * Fixes #1013 (show runtime CPU features in --version output)
What version of ripgrep are you using?
How did you install ripgrep?
From
.deb
binary.What operating system are you using ripgrep on?
Linux Mint 18.1 Serena.
Describe your question, feature request, or bug.
First of all, thanks and congratulations for this tool.
I've searched in the help and in the issues, and as I didn't find anything related, I'm opening this suggestion.
I think that would be nice to add an option for trimming the output of the coincident lines. In other words, not to print the indentation of the lines. I think that this could improve the readability of the output.
Currently, for this search:
I would get the following output:
(Note the code indentation).
With an option for trimming (e.g.
--trim
), we would get the following:(The indentation is now removed from the output).
I really think that this could be a very useful option, since almost every part of the code is indented, except class or function definitions.
PD: this could also work in combination with
--max-columns
option, so the trimming would be done before the output is filtered with this options. But as I know nothing about ripgrep internals and the feasibility and difficulty of this, I just leave it as a little extra suggestion. Actually this wouldn't be very relevant, since the--max-columns
is thought for the output we actually don't want to see. So, if you find appropriate the original suggestion, just implement it as you think it's better for ripgrep. :)Thanks again and keep up the great work!
The text was updated successfully, but these errors were encountered: