One way to do this is by using \zs
to set the "start" of the match, so that everything before \zs
is untouched by the replacement:
:%s/RESULT=\zs.*/200/g
Your original attempt using a lookbehind was also on the right track: you just put the .*
part in the wrong place:
:%s/\(RESULT=\)\@<=.*/200/g
This replaces anything that comes after a RESULT=
, whereas your search replaced nothing that comes after a RESULT=.*
.
However, \zs
and \ze
are recommended over lookarounds when it's possible to use them, because lookarounds can be slow.
As @DJMcMayhem notes in the comments, yet another approach is to allow the substitution command to replace the RESULT=
part, but include that text in the replacement by using a capture group:
:%s/\(RESULT=\).*/\1200