
No tengo claro qué hace la expresión submatch({nr}) en vim. El manual dice lo siguiente:
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.
Entiendo lo que hace la subpartida (0), pero ¿qué significa la '{nr}'ésima subpartida'?
Respuesta1
{nr}ésimo significa {número}ésimo. En este caso sería lo mismo que \0, \1, ... \9 cuando no se usa una expresión en el reemplazo. Ver:
:help /\1
Las subcoincidencias están encerradas por \(...\) en el patrón. Ver:
:help /\(