Clarify documentation for --replace.

Also add a minor clarification for --type-add.

Fixes #147
This commit is contained in:
Andrew Gallant 2016-10-10 20:19:45 -04:00
parent dde5bd5a80
commit 4665128f25
3 changed files with 35 additions and 21 deletions

View File

@ -91,12 +91,6 @@ If a match is found in a file, stop searching that file.
.RS .RS
.RE .RE
.TP .TP
.B \-r, \-\-replace \f[I]ARG\f[]
Replace every match with the string given.
Capture group indices (e.g., $5) and names (e.g., $foo) are supported.
.RS
.RE
.TP
.B \-t, \-\-type \f[I]TYPE\f[] ... .B \-t, \-\-type \f[I]TYPE\f[] ...
Only search files matching TYPE. Only search files matching TYPE.
Multiple type flags may be provided. Multiple type flags may be provided.
@ -259,6 +253,15 @@ Alias for \-\-color=always \-\-heading \-n.
.RS .RS
.RE .RE
.TP .TP
.B \-r, \-\-replace \f[I]ARG\f[]
Replace every match with the string given when printing search results.
Neither this flag nor any other flag will modify your files.
.RS
.PP
Capture group indices (e.g., $5) and names (e.g., $foo) are supported in
the replacement string.
.RE
.TP
.B \-s, \-\-case\-sensitive .B \-s, \-\-case\-sensitive
Search case sensitively. Search case sensitively.
This overrides \-\-ignore\-case and \-\-smart\-case. This overrides \-\-ignore\-case and \-\-smart\-case.
@ -305,10 +308,12 @@ Multiple \-\-type\-add flags can be provided.
Unless \-\-type\-clear is used, globs are added to any existing globs 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.
.RS .RS
.RE
.PP .PP
Example: \f[C]\-\-type\-add\ html:*.html\f[] Example:
\f[C]rg\ \-\-type\-add\ \[aq]foo:*.foo\[aq]\ \-tfoo\ PATTERN\f[]
.RE
.TP .TP
.B \-\-type\-clear \f[I]TYPE\f[] ... .B \-\-type\-clear \f[I]TYPE\f[] ...
Clear the file type globs previously defined for TYPE. Clear the file type globs previously defined for TYPE.

View File

@ -61,10 +61,6 @@ the raw speed of grep.
: Do not print anything to stdout. If a match is found in a file, stop : Do not print anything to stdout. If a match is found in a file, stop
searching that file. searching that file.
-r, --replace *ARG*
: Replace every match with the string given. Capture group indices (e.g., $5)
and names (e.g., $foo) are supported.
-t, --type *TYPE* ... -t, --type *TYPE* ...
: Only search files matching TYPE. Multiple type flags may be provided. Use the : Only search files matching TYPE. Multiple type flags may be provided. Use the
--type-list flag to list all available types. --type-list flag to list all available types.
@ -168,6 +164,13 @@ the raw speed of grep.
-p, --pretty -p, --pretty
: Alias for --color=always --heading -n. : Alias for --color=always --heading -n.
-r, --replace *ARG*
: Replace every match with the string given when printing search results.
Neither this flag nor any other flag will modify your files.
Capture group indices (e.g., $5) and names (e.g., $foo) are supported
in the replacement string.
-s, --case-sensitive -s, --case-sensitive
: Search case sensitively. This overrides --ignore-case and --smart-case. : Search case sensitively. This overrides --ignore-case and --smart-case.
@ -197,9 +200,10 @@ the raw speed of grep.
: Add a new glob for a particular file type. Only one glob can be added : Add a new glob for a particular file type. Only one glob can be added
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. this must be passed to every invocation of rg. Type settings are NOT
persisted.
Example: `--type-add html:*.html` Example: `rg --type-add 'foo:*.foo' -tfoo PATTERN`
--type-clear *TYPE* ... --type-clear *TYPE* ...
: Clear the file type globs previously defined for TYPE. This only clears : Clear the file type globs previously defined for TYPE. This only clears

View File

@ -68,9 +68,6 @@ Common options:
-N, --no-line-number Suppress line numbers. -N, --no-line-number Suppress line numbers.
-q, --quiet Do not print anything to stdout. If a match is -q, --quiet Do not print anything to stdout. If a match is
found in a file, stop searching that file. found in a file, stop searching that file.
-r, --replace ARG Replace every match with the string given.
Capture group indices (e.g., $5) and names
(e.g., $foo) are supported.
-t, --type TYPE ... Only search files matching TYPE. Multiple type -t, --type TYPE ... Only search files matching TYPE. Multiple type
flags may be provided. Use the --type-list flag flags may be provided. Use the --type-list flag
to list all available types. to list all available types.
@ -169,6 +166,13 @@ Less common options:
-p, --pretty -p, --pretty
Alias for --color=always --heading -n. Alias for --color=always --heading -n.
-r, --replace ARG
Replace every match with the string given when printing search results.
Neither this flag nor any other flag will modify your files.
Capture group indices (e.g., $5) and names (e.g., $foo) are supported
in the replacement string.
-s, --case-sensitive -s, --case-sensitive
Search case sensitively. This overrides --ignore-case and --smart-case. Search case sensitively. This overrides --ignore-case and --smart-case.
@ -194,10 +198,11 @@ File type management options:
Show all supported file types and their associated globs. Show all supported file types and their associated globs.
--type-add ARG ... --type-add ARG ...
Add a new glob for a particular file type. Only one glob can be added Add a new glob for a particular file type. Only one glob can be
at a time. Multiple type-add flags can be provided. Unless type-clear added at a time. Multiple --type-add flags can be provided. Unless
is used, globs are added to any existing globs inside of ripgrep. Note --type-clear is used, globs are added to any existing globs inside of
that this must be passed to every invocation of rg. ripgrep. Note that this must be passed to every invocation of rg. Type
settings are NOT persisted.
Example: `--type-add html:*.html` Example: `--type-add html:*.html`