unklar, was Submatch in vim macht

unklar, was Submatch in vim macht

Mir ist nicht klar, was der Ausdruck submatch({nr}) in vim macht. Im Handbuch steht Folgendes:

submatch({nr})                      *submatch()*
    Only for an expression in a |:substitute| command.  Returns
    the {nr}'th submatch of the matched text.  When {nr} is 0
    the whole matched text is returned.
    Example:
        :s/\d\+/\=submatch(0) + 1/
    This finds the first number in the line and adds one to it.
    A line break is included as a newline character.

Ich verstehe, was submatch(0) macht, aber was ist mit dem ,{nr}-ten Submatch‘ gemeint?

Antwort1

{nr}th bedeutet {number}th. In diesem Fall wäre es dasselbe wie \0, \1, ... \9, wenn beim Ersetzen kein Ausdruck verwendet wird. Siehe:

:help /\1

Teilübereinstimmungen werden im Muster durch \(...\) umschlossen. Siehe:

:help /\(

verwandte Informationen