Pergunta

how to call a function from the substitute string in vim? When i have:

%s/regex/string/g and i want the group as argument and replace it with the return value of the function:

%s/regex/call function(\1)/g so the group #1 will be the argument of the function, and the return value of the function will replace all the matches in buffer.

is it posible?

Foi útil?

Solução

To use a vimscript expression you need to add \= to your replacement string:

%s/regex/\= function(submatch(1))/g
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top