ripgrep | Cheatsheet¶
Sort by¶
rg --sort none # (Default) Do not sort results. Fastest. Can be multi-threaded.
rg --sort path # Sort by file path. Always single-threaded.
rg --sort modified # Sort by the last modified time on a file. Always single-threaded.
rg --sort accessed # Sort by the last accessed time on a file. Always single-threaded.
rg --sort created # Sort by the creation time on a file. Always single-threaded.
Sort by descending order¶
rg --sortr none # (Default) Do not sort results. Fastest. Can be multi-threaded.
rg --sortr path # Sort by file path. Always single-threaded.
rg --sortr modified # Sort by the last modified time on a file. Always single-threaded.
rg --sortr accessed # Sort by the last accessed time on a file. Always single-threaded.
rg --sortr created # Sort by the creation time on a file. Always single-threaded.
List directories¶
Very fast history search with ripgrep¶
List matching files only¶
Files Without a Match¶
Use -v to filter out all matches so that only non-matches are left.¶
Displays built-in available types and their corresponding globs¶
Only search in .sh files, -g can be used multiple times¶
Search in all files except .sh files, -g can be used multiple times¶
The following command restricts the search for the pattern "key" to json files only.¶
File separator¶
Path separator¶
List all files that would be searched without actually performing the search.¶
Print all the file types recognized by ripgrep.¶
Show the help message.¶
Display the version of ripgrep.¶
Use the PCRE2 regex engine.¶
Use a provided pattern for search (requires pattern argument).¶
Show column numbers in results.¶
Don't show column numbers in results.¶
Ignore case for the pattern.¶
Show NUM lines after each match (requires NUM argument).¶
Show NUM lines before and after each match (requires NUM argument).¶
Use the best regex engine for each pattern.¶
Specify regex engine to use (requires argument).¶
Search binary files.¶
Search only text files.¶
Search all files, including hidden and binary.¶
Don't search binary files.¶
Use block buffering, which can help speed up searches in large data sets.¶
Disable block buffering.¶
Use line buffering, useful when tailing a file.¶
Print the 0-based byte offset within the input file before each line of output.¶
Show only the part of a line matching the pattern.¶
Use a preprocessor command.¶
Make the pattern case sensitive.¶
Ignore case when matching the pattern.¶
Configure coloring of output.¶
Print results in a format compatible with Vim's 'grepprg' option.¶
Configure colors used in output (requires argument).¶
Display the line numbers with output lines.¶
Show NUM lines before each match (requires NUM argument).¶
Set the string to print between every context line.¶
Do not print a separator between context lines.¶
Only print a count of matches per file.¶
Enable matching across multiple lines.¶
Of course, let's continue with the explanations:
Print the count of matches in each file instead of the matches themselves.¶
Always print the file path with the matched lines.¶
Include zero length files in the search.¶
Print the count of matches in each file instead of the matches themselves.¶
Always print the file path with the matched lines.¶
Print the total number of matches.¶
Treat CRLF ("\r\n") as a line terminator, instead of just "\n".¶
Never treat CRLF ("\r\n") as a line terminator.¶
Show debug messages.¶
Show trace messages. This is more verbose than --debug.¶
Set the size limit of the DFA. Requires argument for size (e.g., --dfa-size-limit 1G).¶
Ignore files larger than SIZE. Requires argument for size (e.g., --max-filesize 1G).¶
Specify the text encoding that ripgrep should use on all files searched. Requires argument for encoding type.¶
Never perform encoding detection and instead search all files as if they were ASCII.¶
Set the regular expression engine. (Requires argument, e.g., --engine pcre2 or --engine auto.)¶
Use a provided pattern for search. (Requires pattern argument.)¶
Search for patterns from the given file. (Requires file argument.)¶
Use the PCRE2 regex engine.¶
Set the field context separator. (Requires argument.)¶
Set the field match separator. (Requires argument.)¶
Search for patterns from the given file. (Requires file argument.)¶
Here are the remaining commands and options with descriptions:
Use a provided pattern for search. (Requires pattern argument.)¶
List all files that would be searched without actually performing the search.¶
Print the names of files that have at least one match.¶
Print the names of files that have no matches.¶
Print the names of files that have no matches.¶
Print the names of files that have at least one match.¶
Print the names of files that have at least one match.¶
Treat the search pattern as a literal string instead of a regular expression.¶
Disable treating the search pattern as a literal string.¶
Follow symbolic links.¶
Do not follow symbolic links.¶
Only search files matching the given glob pattern.¶
Only search files matching the given glob pattern.¶
Perform case-insensitive matching for glob patterns.¶
Only search files matching the given glob pattern.¶
Disable case-insensitive matching for glob patterns.¶
Print the file name above each match.¶
Do not print the file name above each match.¶
Search hidden files and directories.¶
Do not search hidden files and directories.¶
Only search files matching the given glob pattern, case-insensitive.¶
Ignore case when matching the pattern.¶
Make the pattern case-sensitive.¶
Read patterns to ignore from the given file.¶
Read patterns to ignore from the given file.¶
Read case-insensitive patterns to ignore from the given file.¶
Do not read case-insensitive patterns to ignore from the given file.¶
Include zero length files in the search.¶
Only print a count of matches per file.¶
Invert the match: show lines that do not match the pattern.¶
Output search results in JSON format.¶
Disable outputting search results in JSON format.¶
Enable line buffering of the output, useful for streaming or piping to other commands.¶
Show line numbers in search results.¶
Only match whole lines.¶
Only match whole words.¶
Certainly! Here are the explanations for the provided commands and options:
Set the maximum width of the output to N columns.¶
Preview the maximum width of the output without actually performing the search.¶
Set the maximum width of the output to N columns.¶
Set the maximum width of the output to N columns.¶
Disable previewing the maximum width of the output.¶
Limit the number of matches per file to N.¶
Set the maximum directory depth for recursive search to N levels.¶
Set the maximum directory depth for recursive search to N levels.¶
Set the maximum size of files to search to N bytes.¶
Set the maximum size of files to search to N bytes.¶
Use memory-mapped I/O to search files.¶
Set the number of context lines to display around each match.¶
Use memory-mapped I/O to search files.¶
Disable memory-mapped I/O for file searching.¶
Enable matching across multiple lines.¶
Enable matching across multiple lines, treating the entire input as a single line.¶
Enable matching across multiple lines.¶
Disable matching across multiple lines.¶
Enable matching across multiple lines, treating the entire input as a single line.¶
Enable matching across multiple lines.¶
Enable matching across multiple lines.¶
Disable matching across multiple lines, treating the entire input as a single line.¶
Enable matching across multiple lines, treating the entire input as a single line.¶
Enable matching across multiple lines.¶
Enable matching across multiple lines.¶
Disable matching across multiple lines, treating the entire input as a single line.¶
Do not read any configuration files.¶
Do not display the file name with each matched line.¶
Always display the file name with each matched line.¶
Do not display the file name above each group of matches.¶
Do not display the file name above each group of matches.¶
Display the file name above each group of matches.¶
Do not respect ignore files.¶
Do not respect ignore files that start with a dot.¶
Do not respect ignore files that are part of a directory's .ignore
file.¶
Do not respect ignore files.¶
Search all files, including hidden and binary files.¶
Respect ignore files.¶
Do not respect ignore files that start with a dot.¶
Search hidden files and directories.¶
Respect ignore files that are part of a directory's .ignore
file.¶
Do not respect ignore files that exclude patterns from the command-line.¶
Respect ignore files that exclude patterns from the command-line.¶
Do not respect ignore files that list files and directories to ignore.¶
Read patterns to ignore from the given file.¶
Read patterns to ignore from the given file.¶
Do not respect global ignore files.¶
Respect global ignore files.¶
Do not respect ignore files that display warning messages.¶
Respect ignore files that display warning messages.¶
Do not respect ignore files that apply to parent directories.¶
Respect ignore files that apply to parent directories.¶
Do not respect ignore files in version control directories.¶
Do not respect ignore files that apply to parent directories.¶
Respect ignore files in version control directories.¶
Do not print line numbers with the search results.¶
Do not display warning messages.¶
Display warning messages.¶
Disable memory-mapped I/O for file searching.¶
Enable memory-mapped I/O for file searching.¶
Disable PCRE2 Unicode support.¶
Disable Unicode support.¶
Disable Unicode support.¶
Require that the search is performed in a Git repository.¶
Require that the search is performed in a Git repository.¶
Disable Unicode support.¶
Disable Unicode support.¶
Do not perform automatic text encoding detection.¶
Disable Unicode support.¶
Use null bytes ('\0') as line terminators.¶
Only print the count of matches per file.¶
Use null bytes ('\0') as input and output field separators.¶
Use null bytes ('\0') as line terminators.¶
Search only text files.¶
Do not cross file system boundaries.¶
Do not cross file system boundaries.¶
Do not cross file system boundaries.¶
Only print the matched portion of the line.¶
Pass through all data without filtering.¶
Show additional lines of context around each match.¶
Set the separator for paths in the output.¶
Use the PCRE2 regex engine.¶
Enable matching across multiple lines.¶
Disable PCRE2 Unicode support.¶
Disable PCRE2 regex engine support.¶
Show the PCRE2 version used by ripgrep.¶
Use a preprocessor command.¶
Do not use a preprocessor command.¶
Use the given shell glob to determine files to ignore.¶
Search inside compressed files (e.g., zip, gzip).¶
Use the given shell glob to determine files to ignore.¶
Use a preprocessor command.¶
Use a preprocessor command.¶
Use a preprocessor command.¶
Use a preprocessor command.¶
Use the given shell glob to determine files to ignore.¶
Use a preprocessor command.¶
Enable prettified output for JSON search results.¶
Enable or disable colored output.¶
Suppress all error messages.¶
List all files that would be searched without actually performing the search.¶
Set the maximum size of the regex pattern to N bytes.¶
Set the maximum size of files to search to N bytes.¶
Use a provided pattern for search. (Requires pattern argument.)¶
Search for an empty pattern (matches all lines).¶
Replace each match with the given replacement.¶
Only print the matched portion of the line.¶
Search inside compressed files (e.g., zip, gzip).¶
Disable searching inside compressed files.¶
Enable smart case matching (case-insensitive when the pattern is lowercase).¶
Make the search case-sensitive.¶
Sort files by relevance.¶
Sort files by relevance in reverse order.¶
Sort files by relevance in reverse order.¶
Sort files by relevance.¶
Show statistics after search is complete.¶
List all files that would be searched without actually performing the search.¶
Disable displaying search statistics.¶
Search only text files.¶
Search both binary and text files.¶
Disable searching text files.¶
Set the number of threads to use for searching.¶
Trim leading and trailing whitespace from each line.¶
Disable trimming leading and trailing whitespace from each line.¶
Specify the file type(s) to search. (Requires type argument.)¶
List all available file types and their corresponding globs.¶
Specify the file type(s) to search. (Requires type argument.)¶
Specify the file type(s) to search. (Requires type argument.)¶
Add a new file type with associated globs.¶
Add a new file type with associated globs.¶
Add a new file type with associated globs.¶
Add a new file type with associated globs.¶
Add a new file type with associated globs.¶
Add a new file type with associated globs.¶
Add a new file type with associated globs.¶
Clear all file type definitions.¶
List all available file types and their corresponding globs.¶
Exclude the given file type(s) from the search. (Requires type argument.)¶
List all available file types and their corresponding globs.¶
Search all files, including hidden and binary files.¶
Do not respect ignore files.¶
Search hidden files and directories.¶
Output the search results in Vim-compatible format.¶
Always display the file name with each matched line.¶
Display the file name above each group of matches.¶
Do not display the file name with each matched line.¶
Only match whole words.¶
Only match whole lines.¶
Suppress all error messages.¶
Suppress all error messages.¶
Read patterns to ignore from the given file.¶
Read patterns to ignore from the given file.¶
Do not respect ignore files.¶
Search hidden files and directories.¶
Search both binary and text files.¶
Follow symbolic links.¶
Do not respect ignore files.¶
Do not respect ignore files.¶
Do not respect ignore files.¶
Use a provided pattern for search. (Requires pattern argument.)¶
Enable smart case matching (case-insensitive when the pattern is lowercase).¶
Enable smart case matching (case-insensitive when the pattern is lowercase).¶
Add a new file type with associated globs.¶
Add a new file type with associated globs.¶
Search for files that do not match the given glob pattern.¶
Search for files that match the given glob pattern.¶
Search for files that match the given glob pattern.¶
Disable reading configuration files.¶
Make the search case-sensitive.¶
Enable smart case matching (case-insensitive when the pattern is lowercase).¶
Make the search case-sensitive.¶
Disable memory-mapped I/O for file searching.¶
Enable debug mode, printing detailed debug information.¶
Color Examples¶
Match with background color (105, 64, 130) in purple:¶
Match with underline style:¶
Match with bold style and background color (128, 0, 0) in red:¶
Match without bold style and background color (0, 128, 0) in green:¶
Match with intense (bright) background color (0, 0, 255) in blue:¶
Match without intense (bright) background color (255, 255, 0) in yellow:¶
Match with background color (255, 0, 255) in magenta and underline style:¶
Match with background color (0, 255, 255) in cyan without underline style:¶
Match with background color (255, 165, 0) in orange and line with foreground color (255, 255, 255) in white:¶
Match with background color (128, 0, 0) in red and line with foreground color (0, 255, 0) in green:¶
Match with background color (0, 128, 0) in green and line with foreground color (0, 0, 255) in blue:¶
Match with background color (0, 0, 128) in blue and line with foreground color (255, 0, 255) in magenta:¶
Match with background color (128, 128, 128) in gray and line with foreground color (255, 255, 0) in yellow:¶
Match with background color (¶
0, 128, 128) in teal and line with foreground color (255, 0, 0) in red: