The problem here is that Vim is interpreting the
/ character in your replacement as a delimiter character used by the
:substitute command. The syntax of the
:s command is as follows:
The above syntax uses the
/ character to delimit pattern, replacement, and flags; however, some other characters (usually punctuation or symbols) can be used.
To fix your problem, you have two options.
/ characters in your pattern and replacement using
Use a different delimiter character. To avoid escaping, choose one that does not appear in your pattern or replacement. For this case, let's use
Appending to a search pattern is a special situation where we can use some features that are fairly unique to Vim's flavour of regex. Vim has zero-width anchors
\ze that define the start and end (respectively) of the part of your pattern that you want to match. Anything before
\zs or after
\ze in your pattern will not be part of the patch, and thus will remain unaffected by replacement.
Instead of repeating the pattern part in the replacement, we can define the start of the match as the end of the pattern. Below, I'll continue with the technique from Option 2 to avoid escaping.
You can look at it like this: we're replacing an empty string that follows
Note that omitting either of these zero-width anchors is like having
\zs at the start of the pattern and/or
\ze at the end of the pattern.
I noticed you're using
gg for your flags. This is identical to not using any
g in your flags at all -- each
g inverts the global behaviour. If this wasn't merely a typo, I suspect that you might have the
'gdefault' option enabled. This has the effect that using
g will make the substitution not global, and no
g in flags (or
gg) will make it global.
Turning this option off (rather, not turning it on, as it's off by default) will let you use a single
g for the global behaviour.