
Мне непонятно, что делает выражение submatch({nr}) в vim. В руководстве говорится следующее:
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.
Я понимаю, что делает submatch(0), но что означает '{nr}'th submatch'?
решение1
{nr}th означает {number}th. В этом случае это будет то же самое, что \0, \1, ... \9, если не использовать выражение в замене. Смотрите:
:help /\1
Подсовпадения заключены в \(...\) в шаблоне. Смотрите:
:help /\(