I have the following line:
return err
And would like to replace that to:
return fmt.Errorf(": %w", \1)
Which is done easily with something like:
:s/return \v(\k+)/return fmt.Errorf(": %w", \1)/
The problem with this is that after the :s
my cursor position will be at the start of the line (the r
in return
), while it would be much more useful to place it on the :
.
Is there any way to set the cursor position in the substitute replace pattern?
:s
command, using a sub-replace expression, that calls a function\=MyReplace
that drops a mark anywhere on the pattern and the command would then after successful substitution move to that mark. Sounds complicated :/