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?
To use a vimscript expression you need to add \=
to your replacement string:
%s/regex/\= function(submatch(1))/g
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With