In vi(m) regex, you need to escape the +
to make it act as a metacharacter.
:%s/^\(K_.\+\):\("."\)/myvars.setvar(\1,\2)/
Also, the g
flag for :s
means Replace all instances on this line
. If there is truly one instance per line, as your post suggests, then the g
is unnecessary and you instead need to specify that the command should run on all lines in the file -- :%s/...