RGR(1)
π RGR β like, the interactive replacer for ripgrep, bestie
okay so picture this: you're on the command line, you've got a million files, and you need to find-and-replace across all of them. That's rgr, and it's lowkey the most iconic little tool in the RGR(1) manual. She's giving find-and-replace, but make it β¨interactiveβ¨. Let's get into it π«Ά
πΈ NAME πΈ
rgr β an interactive replacer for ripgrep that makes it easy to find and replace across files on the command line. Fr fr, that's the whole vibe.
π DESCRIPTION π
Bestie, real talk: before you can even look at this tool, you gotta have installed rg (AKA: ripgrep) first. No rg, no rgr, periodt. Install deets live here: https://github.com/BurntSushi/ripgrep/#installation π
π USAGE π
β¨ Normal Usage β¨
So when you start her up, literally all your command line arguments get passed down to rg β and she sneaks in --json and --no-config on top, no cap. Then the JSON output gets parsed, and boom, you're looking at a whole terminal interface (the deets are below, keep scrolling π).
Heads up bestie: because we're using the--jsonflag, a bunch ofrg's flags are just, like, unavailable. Not me gatekeeping β that's just how it is. Runrgr --helpto see the list of supported flags that actually get sent through to ripgrep π
π¦ Capturing Groups π¦
You can absolutely use capturing groups with rgr, like this:
rgr "foo (\w+)"
When you do that, you can use the matches while replacing by referring to them either by their name $name or their index $1. This syntax is inherited from the regex crate, iykyk β see: https://docs.rs/regex/1.8.4/regex/struct.Captures.html#method.expand
β οΈ Only one pattern may be passed at a time when capturing groups are used (i.e., multiple -e <pat> flags are not allowed). One pattern. That's the rule. π
β Automatic replacement β
Got no time for the interface? Pass -y or --autoreplace together with -r or --replace and she'll replace every match without ever opening the interactive interface. Iconic. For example:
rgr -y "old_name" -r "new_name"
The replacement must be supplied explicitly β like, you can't just be vague about it. Automatic replacement exits with an error before even searching if -r or --replace is missing. Vibe check failed, no search for you π
π Reading results from a file π
Bestie, she also supports reading results from a JSON file, and here's the use case she had in mind:
- The user runs
rg --json <args> > rg-results.json - Now, this tool can be run with those results via
RGR_JSON_FILE=./rg-results.json rgr
Look at that workflow. Main character energy, honestly π
π INTERFACE π
To see a list of keybindings, press ? while you're in the SELECT mode. There are a few different modes, so let's meet the cast π¬
πΈ SELECT πΈ
- This mode is the first mode presented after
rgris started. She's the opener, the one who walks in first π - In this mode a list of matches is presented, and they can be toggled on or off.
- Toggling a match off means that the match itself will not be replaced. Simple as that.
π¦ REPLACE π¦
- In this mode the user types the desired replacement text and the matches are updated in real-time. So satisfying to watch ngl.
- Note that this is a demo only β no changes are written to disk. It's giving preview, not commitment π
- Non UTF-8 bytes in the matches are shown with the UTF-8 replacement character in this mode.
- Pressing Ctrl+s will cause all selected matches to be replaced with the text entered.
β CONFIRM β
- Prompt the user to confirm before writing replacements to disk. Consent matters, bestie β¨
- Replacements are written to disk, and all attempts to use the correct file encoding are made. (see FILE ENCODING.)
- Note that
rgrwill not replace a different slice of bytes than whatrgreported in its output. (see FILE ENCODING.) She's careful like that.
π HELP π
- This mode provides information about
rgrand its keybindings. When in doubt, press the help button, that's the rule π«Ά
π§ CONTROL CHARACTERS π§
You can change how control characters are rendered in the interface by pressing Ctrl+v. The different modes are:
C: show common control charactersc: show common control characters (one line)A: show all control charactersa: show all control characters (one line)H: show common control characters as spaces, and strip others (hidden)
Capital letters vs lowercase letters β she's detail-oriented, we love her for it π
π₯ FILE ENCODING π₯
Handling of file encoding happens in two places: the SELECT mode and when the replacements are written to disk. Two whole places. She's thorough.
In the SELECT mode, non UTF-8 bytes are shown with the UTF-8 replacement character. Why? Because the files themselves have not yet been read β the information is directly from ripgrep β and thus the encoding of the file is unknown. She's working off secondhand info, give her a break π
During replacement, encoding is handled in the following manner:
- If a BOM (Byte Order Mark) is found, then that encoding is used, otherwise
- If an encoding was passed to ripgrep, then that encoding is used, otherwise
- The chardet (https://github.com/thuleqaid/rust-chardet) library is used to detect the encoding
- If that fails, then UTF8 is assumed
β οΈ Okay this part is important, so listen up: rgr will never replace a match that it doesn't expect. If, when replacing a match, the bytes to replace do not match those matched by ripgrep, then the tool will bail out and the file will not be written. (Errors will be reported to STDERR.)
Like, she'd rather give up than get it wrong. Respect honestly π
π HOMEPAGE π
https://github.com/acheronfail/repgrep
Go give her a star, she deserves it β
π BUGS AND FEATURES π
Please report bugs and feature requests in the issue tracker. Do your best to provide a reproducible test case for bugs β the more reproducible the better, bestie, we're begging π₯Ί Also please include the version of rgr and rg. Both of them. Don't make her guess.
and that's the whole manual, you're officially caught up π this page was brought to you by RGR(1), dated 2026-09-02 β mwah, go forth and replace things responsibly πβ¨
π¦ where this page comes from
- arch rolling: repgrep 0.17.1-1 Β· MIT AND Apache AND Unlicense
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms