When the {string} starts with "\=" it is evaluated as an expression, which provides additional flexibility.
To demonstrate a simple example of substitution with an expression, let's repeat the example from the previous section with an expression.
As before we will start with the following buffer:
and use the same search pattern.
The replacement string can contain a complex expression, containing. For example, in this example we
will combine string concatenation with the submatch
function to replicate the previous result:
\=submatch(3).', '.submatch(1).' '.submatch(2)
Which, when executed, yields the expected result:
This example was intended to show a simple example of how to implement a substitution that leverages expressions, rather than demonstrate the additional flexibility that expressions offer.