docs: mention backreferences (for replacements with regular expressions)

Also mention that nano prompts for each occurrence, and that, when
a region is marked, replacements are made only within that region.
This commit is contained in:
Benno Schulenberg 2024-03-05 15:50:15 +01:00
parent a13cd6a177
commit 5bd5bcd06a

View File

@ -310,15 +310,32 @@ If needed, it can be toggled off manually with another @kbd{^6} or @kbd{M-A}.
@node Search and Replace
@section Search and Replace
One can search the current buffer for the occurrence of any string
with the Search command (default key binding: @kbd{^W}). The default search
With the Search command (@kbd{^F} or @kbd{^W}) one can search the
current buffer for the occurrence of any string. The default search
mode is forward, case-insensitive, and for literal strings. But one
can search backwards by pressing @kbd{M-B}, search case sensitively with @kbd{M-C},
and interpret regular expressions in the search string with @kbd{M-R}.
can search backwards by toggling @kbd{M-B}, search case sensitively
with @kbd{M-C}, and interpret regular expressions in the search string
with @kbd{M-R}.
A regular expression in a search string always covers just one line;
it cannot span multiple lines. And when replacing (with @kbd{^\} or @kbd{M-R})
the replacement string cannot contain a newline (LF).
With the Replacement command (@kbd{M-R} or @kbd{^\}) one can replace
a given string (or regular expression) with another string.
When a regular expression contains fragments between parentheses,
the replacement string can refer back to these fragments via
@code{\1} to @code{\9}.
For each occurrence of the search string you will be asked whether to
replace it. You can choose Yes (replace it), or No (skip this one),
or All (replace all remaining occurrences without asking any more),
or Cancel (stop with replacing, but replacements that have already
been made will not be undone).
If before a replacing session starts a region is marked, then
only occurrences of the search string within the marked region
will be replaced.
A regular expression always covers just one line --- it cannot span
multiple lines. And neither a search string nor a replacement string
can contain a newline (LF).
@node Using the Mouse
@section Using the Mouse