Extract and use part of a string with regex in GVIM
1 answer
You can use this:
%s/\vdoCall\(<(\w*)>,/\1 = doCall(\1,/
\v
allows "more magic" in regular expressions - not necessary here, but I usually use it to simplify expressions. <…>
matches the word boundaries and the intermediate matches the first parameter and puts it in the first capture group. Replacement uses \1
grab and paste to access this group at the correct two locations.
+1
a source to share