You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add option to customize the separator character betwen paths, lines, columns and matches #1842
As of version 12.1.1, if the --no-heading option is used then a : will be used to separate paths, lines, columns (if the --column option is used) and matches. Is it possible to customize those characters individually?
For example I'd like to use a @ between paths and lines, the default : between lines and columns and a space between columns and matches.
I'm new to ripgrep, I've read the manual but I haven't found anything about it so I assume this behaviour is not currently supported?
I'm also keen to have this feature, and my use-case is to make sure that the file path and line number are presented in the terminal in a way that can be ctrl+left clicked such that they will open to that line in VSCode.
$ rg use
src/entries.rs:186:use super::*;
src/entries.rs:187:use std::io::Cursor;
src/entries.rs:188:use test_case::test_case;
Sometimes, the fact that there is no space after the 2nd colon on each line makes it such that VSCode won't open the file at that line, instead it will initiate a search that yields nothing. Having a space there makes this work 100% of the time.
I've forked the repo and started taking a preliminary look. If I manually change line 789 of ripgrep/crates/core/args.rs to be a space instead of a colon, it doesn't quite do what I'd like. I'd like to be able to keep the colon between the path and the line number, but have a space between the line number and the match.
Would you be open to accepting a PR that changes the printer crate to allow this?
@samwho Possibly. It depends on if there are any performance problems created by accepting multiple bytes vs one byte. It's been a while since I've touched that code, but my instinct is that there shouldn't be.
@samwho did you come up with a solution? I have the same problem with VSCode link detection, and --field-match-separator " " doesn't quite do what I want, as I lose the line number when clicking a link.
Activity
BurntSushi commentedon Apr 3, 2021
There is no way to customize it. But the underlying library does support customizing it:
ripgrep/crates/core/args.rs
Lines 789 to 790 in 7923d25
I think I would be OK with a PR that adds two flags, one each for customizing the match and context separators for fields emitted in each case.
As a hint, you'll want to use
cli::unescape_osto extract out the separator from the CLI argument.samwho commentedon Apr 9, 2021
I'm also keen to have this feature, and my use-case is to make sure that the file path and line number are presented in the terminal in a way that can be ctrl+left clicked such that they will open to that line in VSCode.
I use the following settings:
And the output looks like this:
Sometimes, the fact that there is no space after the 2nd colon on each line makes it such that VSCode won't open the file at that line, instead it will initiate a search that yields nothing. Having a space there makes this work 100% of the time.
Removing
--trimisn't a solution.samwho commentedon Apr 9, 2021
I've forked the repo and started taking a preliminary look. If I manually change line 789 of
ripgrep/crates/core/args.rsto be a space instead of a colon, it doesn't quite do what I'd like. I'd like to be able to keep the colon between the path and the line number, but have a space between the line number and the match.Would you be open to accepting a PR that changes the
printercrate to allow this?BurntSushi commentedon Apr 9, 2021
@samwho Possibly. It depends on if there are any performance problems created by accepting multiple bytes vs one byte. It's been a while since I've touched that code, but my instinct is that there shouldn't be.
cli: add --field-{context,match}-separator flags
cli: add --field-{context,match}-separator flags
fallaciousreasoning commentedon Jul 18, 2022
@samwho did you come up with a solution? I have the same problem with VSCode link detection, and
--field-match-separator " "doesn't quite do what I want, as I lose the line number when clicking a link.samwho commentedon Jul 19, 2022
I'm afraid I didn't.
cli: add --field-{context,match}-separator flags