mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-05-19 09:40:22 -07:00
Update help and man pages
Formatting of rg.1.md. Remove backticks from already indented code. Add missing italic to some arguments, Replace -n by --line-number in --pretty for better clarity. Add explicit example of `*.foo` instead of `<glob>` in examples. Add vim information to --vimgrep. In src/app.rs, also changed help text for pattern and regexp. Actually, "multiple patterns may be given" was not true for the standalone pattern.
This commit is contained in:
parent
ff898cd105
commit
4c78ca8b70
80
doc/rg.1
80
doc/rg.1
@ -7,12 +7,12 @@
|
|||||||
rg \- recursively search current directory for lines matching a pattern
|
rg \- recursively search current directory for lines matching a pattern
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.PP
|
.PP
|
||||||
rg [\f[I]options\f[]] <\f[I]pattern\f[]> [\f[I]<\f[]path\f[I]> ...\f[]]
|
rg [\f[I]options\f[]] \f[I]PATTERN\f[] [\f[I]path\f[] ...]
|
||||||
.PP
|
.PP
|
||||||
rg [\f[I]options\f[]] (\-e PATTERN | \-f FILE) ...
|
rg [\f[I]options\f[]] [\-e \f[I]pattern\f[] ...] [\-f \f[I]file\f[] ...]
|
||||||
[\f[I]<\f[]path\f[I]> ...\f[]]
|
[\f[I]path\f[] ...]
|
||||||
.PP
|
.PP
|
||||||
rg [\f[I]options\f[]] \-\-files [\f[I]<\f[]path\f[I]> ...\f[]]
|
rg [\f[I]options\f[]] \-\-files [\f[I]path\f[] ...]
|
||||||
.PP
|
.PP
|
||||||
rg [\f[I]options\f[]] \-\-type\-list
|
rg [\f[I]options\f[]] \-\-type\-list
|
||||||
.PP
|
.PP
|
||||||
@ -71,22 +71,23 @@ Multiple glob flags may be used.
|
|||||||
Globbing rules match .gitignore globs.
|
Globbing rules match .gitignore globs.
|
||||||
Precede a glob with a \[aq]!\[aq] to exclude it.
|
Precede a glob with a \[aq]!\[aq] to exclude it.
|
||||||
.RS
|
.RS
|
||||||
.RE
|
|
||||||
.PP
|
.PP
|
||||||
The \-\-glob flag subsumes the functionality of both the \-\-include and
|
The \-\-glob flag subsumes the functionality of both the \-\-include and
|
||||||
\-\-exclude flags commonly found in other tools.
|
\-\-exclude flags commonly found in other tools.
|
||||||
|
.PP
|
||||||
|
Values given to \-g must be quoted or your shell will expand them and
|
||||||
|
result in unexpected behavior.
|
||||||
|
.PP
|
||||||
|
Combine with the \-\-files flag to return matched filenames (i.e., to
|
||||||
|
replicate ack/ag\[aq]s \-g flag).
|
||||||
|
For example:
|
||||||
.IP
|
.IP
|
||||||
.nf
|
.nf
|
||||||
\f[C]
|
\f[C]
|
||||||
Values\ given\ to\ \-g\ must\ be\ quoted\ or\ your\ shell\ will\ expand\ them\ and\ result
|
rg\ \-g\ \[aq]*.foo\[aq]\ \-\-files
|
||||||
in\ unexpected\ behavior.
|
|
||||||
|
|
||||||
Combine\ with\ the\ \-\-files\ flag\ to\ return\ matched\ filenames
|
|
||||||
(i.e.,\ to\ replicate\ ack/ag\[aq]s\ \-g\ flag).
|
|
||||||
|
|
||||||
For\ example:\ rg\ \-g\ \[aq]\\<glob\\>\[aq]\ \-\-files
|
|
||||||
\f[]
|
\f[]
|
||||||
.fi
|
.fi
|
||||||
|
.RE
|
||||||
.TP
|
.TP
|
||||||
.B \-h, \-\-help
|
.B \-h, \-\-help
|
||||||
Show this usage message.
|
Show this usage message.
|
||||||
@ -134,14 +135,15 @@ Reduce the level of \[aq]smart\[aq] searching.
|
|||||||
A single \-u doesn\[aq]t respect .gitignore (etc.) files.
|
A single \-u doesn\[aq]t respect .gitignore (etc.) files.
|
||||||
Two \-u flags will search hidden files and directories.
|
Two \-u flags will search hidden files and directories.
|
||||||
Three \-u flags will search binary files.
|
Three \-u flags will search binary files.
|
||||||
\-uu is equivalent to grep \-r, and \-uuu is equivalent to grep \-a \-r.
|
\-uu is equivalent to \f[C]grep\ \-r\f[], and \-uuu is equivalent to
|
||||||
|
\f[C]grep\ \-a\ \-r\f[].
|
||||||
.RS
|
.RS
|
||||||
.PP
|
.PP
|
||||||
Note that the \-u flags are convenient aliases for other combinations of
|
Note that the \-u flags are convenient aliases for other combinations of
|
||||||
flags.
|
flags.
|
||||||
\-u aliases \[aq]\-\-no\-ignore\[aq].
|
\-u aliases \-\-no\-ignore.
|
||||||
\-uu aliases \[aq]\-\-no\-ignore \-\-hidden\[aq].
|
\-uu aliases \-\-no\-ignore \-\-hidden.
|
||||||
\-uuu aliases \[aq]\-\-no\-ignore \-\-hidden \-\-text\[aq].
|
\-uuu aliases \-\-no\-ignore \-\-hidden \-\-text.
|
||||||
.RE
|
.RE
|
||||||
.TP
|
.TP
|
||||||
.B \-v, \-\-invert\-match
|
.B \-v, \-\-invert\-match
|
||||||
@ -188,9 +190,12 @@ A special format, {type}:none, will clear all color settings for {type}.
|
|||||||
.PP
|
.PP
|
||||||
For example, the following command will change the match color to
|
For example, the following command will change the match color to
|
||||||
magenta and the background color for line numbers to yellow:
|
magenta and the background color for line numbers to yellow:
|
||||||
.PP
|
.IP
|
||||||
rg \-\-colors \[aq]match:fg:magenta\[aq] \-\-colors
|
.nf
|
||||||
\[aq]line:bg:yellow\[aq] foo.
|
\f[C]
|
||||||
|
rg\ \-\-colors\ \[aq]match:fg:magenta\[aq]\ \-\-colors\ \[aq]line:bg:yellow\[aq]\ foo.
|
||||||
|
\f[]
|
||||||
|
.fi
|
||||||
.RE
|
.RE
|
||||||
.TP
|
.TP
|
||||||
.B \-\-column
|
.B \-\-column
|
||||||
@ -223,7 +228,7 @@ https://encoding.spec.whatwg.org/#concept\-encoding\-get
|
|||||||
.RS
|
.RS
|
||||||
.RE
|
.RE
|
||||||
.TP
|
.TP
|
||||||
.B \-f, \-\-file FILE ...
|
.B \-f, \-\-file \f[I]FILE\f[] ...
|
||||||
Search for patterns from the given file, with one pattern per line.
|
Search for patterns from the given file, with one pattern per line.
|
||||||
When this flag is used or multiple times or in combination with the
|
When this flag is used or multiple times or in combination with the
|
||||||
\-e/\-\-regexp flag, then all patterns provided are searched.
|
\-e/\-\-regexp flag, then all patterns provided are searched.
|
||||||
@ -237,8 +242,12 @@ Print each file that would be searched (but don\[aq]t search).
|
|||||||
.RS
|
.RS
|
||||||
.PP
|
.PP
|
||||||
Combine with the \-g flag to return matched paths, for example:
|
Combine with the \-g flag to return matched paths, for example:
|
||||||
.PP
|
.IP
|
||||||
rg \-g \[aq]<glob>\[aq] \-\-files
|
.nf
|
||||||
|
\f[C]
|
||||||
|
rg\ \-g\ \[aq]*.foo\[aq]\ \-\-files
|
||||||
|
\f[]
|
||||||
|
.fi
|
||||||
.RE
|
.RE
|
||||||
.TP
|
.TP
|
||||||
.B \-l, \-\-files\-with\-matches
|
.B \-l, \-\-files\-with\-matches
|
||||||
@ -284,7 +293,7 @@ Search hidden directories and files.
|
|||||||
.RS
|
.RS
|
||||||
.RE
|
.RE
|
||||||
.TP
|
.TP
|
||||||
.B \-\-ignore\-file FILE ...
|
.B \-\-ignore\-file \f[I]FILE\f[] ...
|
||||||
Specify additional ignore files for filtering file paths.
|
Specify additional ignore files for filtering file paths.
|
||||||
Ignore files should be in the gitignore format and are matched relative
|
Ignore files should be in the gitignore format and are matched relative
|
||||||
to the current working directory.
|
to the current working directory.
|
||||||
@ -387,7 +396,7 @@ A path separator is limited to a single byte.
|
|||||||
.RE
|
.RE
|
||||||
.TP
|
.TP
|
||||||
.B \-p, \-\-pretty
|
.B \-p, \-\-pretty
|
||||||
Alias for \-\-color=always \-\-heading \-n.
|
Alias for \-\-color=always \-\-heading \-\-line\-number.
|
||||||
.RS
|
.RS
|
||||||
.RE
|
.RE
|
||||||
.TP
|
.TP
|
||||||
@ -446,9 +455,21 @@ Show the version number of ripgrep and exit.
|
|||||||
.B \-\-vimgrep
|
.B \-\-vimgrep
|
||||||
Show results with every match on its own line, including line numbers
|
Show results with every match on its own line, including line numbers
|
||||||
and column numbers.
|
and column numbers.
|
||||||
(With this option, a line with more than one match of the regex will be
|
With this option, a line with more than one match will be printed more
|
||||||
printed more than once.)
|
than once.
|
||||||
.RS
|
.RS
|
||||||
|
.PP
|
||||||
|
Recommended .vimrc configuration:
|
||||||
|
.IP
|
||||||
|
.nf
|
||||||
|
\f[C]
|
||||||
|
\ \ set\ grepprg=rg\\\ \-\-vimgrep
|
||||||
|
\ \ set\ grepformat^=%f:%l:%c:%m
|
||||||
|
\f[]
|
||||||
|
.fi
|
||||||
|
.PP
|
||||||
|
Use :grep to grep for something, then :cn and :cp to navigate through
|
||||||
|
the matches.
|
||||||
.RE
|
.RE
|
||||||
.SH FILE TYPE MANAGEMENT OPTIONS
|
.SH FILE TYPE MANAGEMENT OPTIONS
|
||||||
.TP
|
.TP
|
||||||
@ -465,11 +486,12 @@ Unless \-\-type\-clear is used, globs are added to any existing globs
|
|||||||
inside of ripgrep.
|
inside of ripgrep.
|
||||||
Note that this must be passed to every invocation of rg.
|
Note that this must be passed to every invocation of rg.
|
||||||
Type settings are NOT persisted.
|
Type settings are NOT persisted.
|
||||||
|
Example:
|
||||||
.RS
|
.RS
|
||||||
.IP
|
.IP
|
||||||
.nf
|
.nf
|
||||||
\f[C]
|
\f[C]
|
||||||
\ \ Example:\ `rg\ \-\-type\-add\ \[aq]foo:*.foo\[aq]\ \-tfoo\ PATTERN`
|
\ \ rg\ \-\-type\-add\ \[aq]foo:*.foo\[aq]\ \-tfoo\ PATTERN
|
||||||
\f[]
|
\f[]
|
||||||
.fi
|
.fi
|
||||||
.PP
|
.PP
|
||||||
@ -483,7 +505,7 @@ Markdown files, one can use:
|
|||||||
.IP
|
.IP
|
||||||
.nf
|
.nf
|
||||||
\f[C]
|
\f[C]
|
||||||
\ \ `\-\-type\-add\ \[aq]src:include:cpp,py,md\[aq]`
|
\ \ \-\-type\-add\ \[aq]src:include:cpp,py,md\[aq]
|
||||||
\f[]
|
\f[]
|
||||||
.fi
|
.fi
|
||||||
.PP
|
.PP
|
||||||
@ -492,7 +514,7 @@ Additional glob rules can still be added to the src type by using the
|
|||||||
.IP
|
.IP
|
||||||
.nf
|
.nf
|
||||||
\f[C]
|
\f[C]
|
||||||
\ \ `\-\-type\-add\ \[aq]src:include:cpp,py,md\[aq]\ \-\-type\-add\ \[aq]src:*.foo\[aq]`
|
\ \ \-\-type\-add\ \[aq]src:include:cpp,py,md\[aq]\ \-\-type\-add\ \[aq]src:*.foo\[aq]
|
||||||
\f[]
|
\f[]
|
||||||
.fi
|
.fi
|
||||||
.PP
|
.PP
|
||||||
|
48
doc/rg.1.md
48
doc/rg.1.md
@ -4,11 +4,11 @@ rg - recursively search current directory for lines matching a pattern
|
|||||||
|
|
||||||
# SYNOPSIS
|
# SYNOPSIS
|
||||||
|
|
||||||
rg [*options*] <*pattern*> [*<*path*> ...*]
|
rg [*options*] *PATTERN* [*path* ...]
|
||||||
|
|
||||||
rg [*options*] (-e PATTERN | -f FILE) ... [*<*path*> ...*]
|
rg [*options*] [-e *pattern* ...] [-f *file* ...] [*path* ...]
|
||||||
|
|
||||||
rg [*options*] --files [*<*path*> ...*]
|
rg [*options*] --files [*path* ...]
|
||||||
|
|
||||||
rg [*options*] --type-list
|
rg [*options*] --type-list
|
||||||
|
|
||||||
@ -61,9 +61,9 @@ Project home page: https://github.com/BurntSushi/ripgrep
|
|||||||
in unexpected behavior.
|
in unexpected behavior.
|
||||||
|
|
||||||
Combine with the --files flag to return matched filenames
|
Combine with the --files flag to return matched filenames
|
||||||
(i.e., to replicate ack/ag's -g flag).
|
(i.e., to replicate ack/ag's -g flag). For example:
|
||||||
|
|
||||||
For example: rg -g '\<glob\>' --files
|
rg -g '*.foo' --files
|
||||||
|
|
||||||
-h, --help
|
-h, --help
|
||||||
: Show this usage message.
|
: Show this usage message.
|
||||||
@ -91,12 +91,12 @@ Project home page: https://github.com/BurntSushi/ripgrep
|
|||||||
-u, --unrestricted ...
|
-u, --unrestricted ...
|
||||||
: Reduce the level of 'smart' searching. A single -u doesn't respect .gitignore
|
: Reduce the level of 'smart' searching. A single -u doesn't respect .gitignore
|
||||||
(etc.) files. Two -u flags will search hidden files and directories. Three
|
(etc.) files. Two -u flags will search hidden files and directories. Three
|
||||||
-u flags will search binary files. -uu is equivalent to grep -r, and -uuu is
|
-u flags will search binary files. -uu is equivalent to `grep -r`, and -uuu
|
||||||
equivalent to grep -a -r.
|
is equivalent to `grep -a -r`.
|
||||||
|
|
||||||
Note that the -u flags are convenient aliases for other combinations of
|
Note that the -u flags are convenient aliases for other combinations of
|
||||||
flags. -u aliases '--no-ignore'. -uu aliases '--no-ignore --hidden'.
|
flags. -u aliases --no-ignore. -uu aliases --no-ignore --hidden.
|
||||||
-uuu aliases '--no-ignore --hidden --text'.
|
-uuu aliases --no-ignore --hidden --text.
|
||||||
|
|
||||||
-v, --invert-match
|
-v, --invert-match
|
||||||
: Invert matching.
|
: Invert matching.
|
||||||
@ -152,7 +152,7 @@ Project home page: https://github.com/BurntSushi/ripgrep
|
|||||||
Other supported values can be found in the list of labels here:
|
Other supported values can be found in the list of labels here:
|
||||||
https://encoding.spec.whatwg.org/#concept-encoding-get
|
https://encoding.spec.whatwg.org/#concept-encoding-get
|
||||||
|
|
||||||
-f, --file FILE ...
|
-f, --file *FILE* ...
|
||||||
: Search for patterns from the given file, with one pattern per line. When this
|
: Search for patterns from the given file, with one pattern per line. When this
|
||||||
flag is used or multiple times or in combination with the -e/--regexp flag,
|
flag is used or multiple times or in combination with the -e/--regexp flag,
|
||||||
then all patterns provided are searched. Empty pattern lines will match all
|
then all patterns provided are searched. Empty pattern lines will match all
|
||||||
@ -163,7 +163,7 @@ Project home page: https://github.com/BurntSushi/ripgrep
|
|||||||
|
|
||||||
Combine with the -g flag to return matched paths, for example:
|
Combine with the -g flag to return matched paths, for example:
|
||||||
|
|
||||||
rg -g '\<glob\>' --files
|
rg -g '*.foo' --files
|
||||||
|
|
||||||
-l, --files-with-matches
|
-l, --files-with-matches
|
||||||
: Only show path of each file with matches.
|
: Only show path of each file with matches.
|
||||||
@ -192,7 +192,7 @@ Project home page: https://github.com/BurntSushi/ripgrep
|
|||||||
: Search hidden directories and files. (Hidden directories and files are
|
: Search hidden directories and files. (Hidden directories and files are
|
||||||
skipped by default.)
|
skipped by default.)
|
||||||
|
|
||||||
--ignore-file FILE ...
|
--ignore-file *FILE* ...
|
||||||
: Specify additional ignore files for filtering file paths.
|
: Specify additional ignore files for filtering file paths.
|
||||||
Ignore files should be in the gitignore format and are matched
|
Ignore files should be in the gitignore format and are matched
|
||||||
relative to the current working directory. These ignore files
|
relative to the current working directory. These ignore files
|
||||||
@ -260,7 +260,7 @@ Project home page: https://github.com/BurntSushi/ripgrep
|
|||||||
cygwin). A path separator is limited to a single byte.
|
cygwin). A path separator is limited to a single byte.
|
||||||
|
|
||||||
-p, --pretty
|
-p, --pretty
|
||||||
: Alias for --color=always --heading -n.
|
: Alias for --color=always --heading --line-number.
|
||||||
|
|
||||||
-r, --replace *ARG*
|
-r, --replace *ARG*
|
||||||
: Replace every match with the string given when printing search results.
|
: Replace every match with the string given when printing search results.
|
||||||
@ -295,9 +295,17 @@ Project home page: https://github.com/BurntSushi/ripgrep
|
|||||||
: Show the version number of ripgrep and exit.
|
: Show the version number of ripgrep and exit.
|
||||||
|
|
||||||
--vimgrep
|
--vimgrep
|
||||||
: Show results with every match on its own line, including line
|
: Show results with every match on its own line, including
|
||||||
numbers and column numbers. (With this option, a line with more
|
line numbers and column numbers. With this option, a line with
|
||||||
than one match of the regex will be printed more than once.)
|
more than one match will be printed more than once.
|
||||||
|
|
||||||
|
Recommended .vimrc configuration:
|
||||||
|
|
||||||
|
set grepprg=rg\ --vimgrep
|
||||||
|
set grepformat^=%f:%l:%c:%m
|
||||||
|
|
||||||
|
Use :grep to grep for something, then :cn and :cp to navigate through the
|
||||||
|
matches.
|
||||||
|
|
||||||
# FILE TYPE MANAGEMENT OPTIONS
|
# FILE TYPE MANAGEMENT OPTIONS
|
||||||
|
|
||||||
@ -309,9 +317,9 @@ Project home page: https://github.com/BurntSushi/ripgrep
|
|||||||
at a time. Multiple --type-add flags can be provided. Unless --type-clear
|
at a time. Multiple --type-add flags can be provided. Unless --type-clear
|
||||||
is used, globs are added to any existing globs inside of ripgrep. Note that
|
is used, globs are added to any existing globs inside of ripgrep. Note that
|
||||||
this must be passed to every invocation of rg. Type settings are NOT
|
this must be passed to every invocation of rg. Type settings are NOT
|
||||||
persisted.
|
persisted. Example:
|
||||||
|
|
||||||
Example: `rg --type-add 'foo:*.foo' -tfoo PATTERN`
|
rg --type-add 'foo:*.foo' -tfoo PATTERN
|
||||||
|
|
||||||
--type-add can also be used to include rules from other types
|
--type-add can also be used to include rules from other types
|
||||||
with the special include directive. The include directive
|
with the special include directive. The include directive
|
||||||
@ -321,12 +329,12 @@ Project home page: https://github.com/BurntSushi/ripgrep
|
|||||||
type called src that matches C++, Python and Markdown files, one
|
type called src that matches C++, Python and Markdown files, one
|
||||||
can use:
|
can use:
|
||||||
|
|
||||||
`--type-add 'src:include:cpp,py,md'`
|
--type-add 'src:include:cpp,py,md'
|
||||||
|
|
||||||
Additional glob rules can still be added to the src type by
|
Additional glob rules can still be added to the src type by
|
||||||
using the --type-add flag again:
|
using the --type-add flag again:
|
||||||
|
|
||||||
`--type-add 'src:include:cpp,py,md' --type-add 'src:*.foo'`
|
--type-add 'src:include:cpp,py,md' --type-add 'src:*.foo'
|
||||||
|
|
||||||
Note that type names must consist only of Unicode letters or
|
Note that type names must consist only of Unicode letters or
|
||||||
numbers. Punctuation characters are not allowed.
|
numbers. Punctuation characters are not allowed.
|
||||||
|
21
src/app.rs
21
src/app.rs
@ -14,10 +14,10 @@ Project home page: https://github.com/BurntSushi/ripgrep
|
|||||||
Use -h for short descriptions and --help for more details.";
|
Use -h for short descriptions and --help for more details.";
|
||||||
|
|
||||||
const USAGE: &'static str = "
|
const USAGE: &'static str = "
|
||||||
rg [OPTIONS] <pattern> [<path> ...]
|
rg [options] PATTERN [path ...]
|
||||||
rg [OPTIONS] [-e PATTERN | -f FILE ]... [<path> ...]
|
rg [options] [-e pattern ...] [-f file ...] [path ...]
|
||||||
rg [OPTIONS] --files [<path> ...]
|
rg [options] --files [path ...]
|
||||||
rg [OPTIONS] --type-list";
|
rg [options] --type-list";
|
||||||
|
|
||||||
const TEMPLATE: &'static str = "\
|
const TEMPLATE: &'static str = "\
|
||||||
{bin} {version}
|
{bin} {version}
|
||||||
@ -203,12 +203,13 @@ lazy_static! {
|
|||||||
|
|
||||||
doc!(h, "pattern",
|
doc!(h, "pattern",
|
||||||
"A regular expression used for searching.",
|
"A regular expression used for searching.",
|
||||||
"A regular expression used for searching. Multiple patterns \
|
"A regular expression used for searching. To match a pattern \
|
||||||
may be given. To match a pattern beginning with a -, use [-].");
|
beginning with a dash, use the -e/--regexp option.");
|
||||||
doc!(h, "regexp",
|
doc!(h, "regexp",
|
||||||
"A regular expression used for searching.",
|
"Use pattern to search.",
|
||||||
"A regular expression used for searching. Multiple patterns \
|
"Use pattern to search. This option can be provided multiple \
|
||||||
may be given. To match a pattern beginning with a -, use [-].");
|
times, where all patterns given are searched. This is also \
|
||||||
|
useful when searching for patterns that start with a dash.");
|
||||||
doc!(h, "path",
|
doc!(h, "path",
|
||||||
"A file or directory to search.",
|
"A file or directory to search.",
|
||||||
"A file or directory to search. Directories are searched \
|
"A file or directory to search. Directories are searched \
|
||||||
@ -447,7 +448,7 @@ lazy_static! {
|
|||||||
default when the environment demands it (e.g., cygwin). A path \
|
default when the environment demands it (e.g., cygwin). A path \
|
||||||
separator is limited to a single byte.");
|
separator is limited to a single byte.");
|
||||||
doc!(h, "pretty",
|
doc!(h, "pretty",
|
||||||
"Alias for --color always --heading -n.");
|
"Alias for --color always --heading --line-number.");
|
||||||
doc!(h, "replace",
|
doc!(h, "replace",
|
||||||
"Replace matches with string given.",
|
"Replace matches with string given.",
|
||||||
"Replace every match with the string given when printing \
|
"Replace every match with the string given when printing \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user