
Não estou claro o que a expressão submatch({nr}) no vim faz. O manual diz o seguinte:
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.
Eu entendo o que submatch(0) faz, mas o que significa '{nr}'th submatch'?
Responder1
{nr}º significa {número}º. Neste caso seria o mesmo que \0, \1, ... \9 quando não estiver usando uma expressão na substituição. Ver:
:help /\1
As subcorrespondências são delimitadas por \(...\) no padrão. Ver:
:help /\(