From aea2369b507fafe34e18152f3b9f017bcef0bfee Mon Sep 17 00:00:00 2001 From: gsspdev Date: Fri, 2 May 2025 22:33:02 -0500 Subject: [PATCH] rg: add short options, simplify language (#16298) Co-authored-by: Managor <42655600+Managor@users.noreply.github.com> Co-authored-by: Lena <126529524+acuteenvy@users.noreply.github.com> --- pages/common/rg.md | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/pages/common/rg.md b/pages/common/rg.md index 77354e095a..2e32deb255 100644 --- a/pages/common/rg.md +++ b/pages/common/rg.md @@ -2,36 +2,36 @@ > Ripgrep, a recursive line-oriented search tool. > Aims to be a faster alternative to `grep`. -> More information: . +> More information: . -- Recursively search the current directory for a regular expression: +- Recursively search current directory for a pattern (regular expression): -`rg {{regular_expression}}` +`rg {{pattern}}` -- Search for regular expressions recursively in the current directory, including hidden files and files listed in `.gitignore`: +- Recursively search for a pattern in a file or directory: -`rg --no-ignore --hidden {{regular_expression}}` +`rg {{pattern}} {{path/to/directory}}` -- Search for a regular expression only in a subset of directories: +- Include hidden files and entries listed in `.gitignore`: -`rg {{regular_expression}} {{set_of_subdirs}}` +`rg {{[-.|--hidden]}} --no-ignore {{pattern}}` -- Search for a regular expression in files matching a glob (e.g. `README.*`): +- Only search the files whose names match the glob pattern(s) (e.g. `README.*`): -`rg {{regular_expression}} --glob {{glob}}` +`rg {{pattern}} {{[-g|--glob]}} {{filename_glob_pattern}}` -- Search for filenames that match a regular expression: +- Recursively list filenames in the current directory that match a pattern: -`rg --files | rg {{regular_expression}}` +`rg --files | rg {{pattern}}` - Only list matched files (useful when piping to other commands): -`rg --files-with-matches {{regular_expression}}` +`rg {{[-l|--files-with-matches]}} {{pattern}}` -- Show lines that do not match the given regular expression: +- Show lines that do not match the pattern: -`rg --invert-match {{regular_expression}}` +`rg {{[-v|--invert-match]}} {{pattern}}` -- Search a literal string pattern: +- Search for a literal string pattern: -`rg --fixed-strings -- {{string}}` +`rg {{[-F|--fixed-strings]}} -- {{string}}`