Q: vim substitution of register following capture group Unexpected behavior of the :s[ubstitution] function.
Given the file:
dog
cat
cow

And a populated register 'a':
let @a='fish'

Executing the following command:
:%s/\(cat\)/\1\=@a/g

Modifies the file to be:
dog
cat=@a
cow

Where I would expect the output to be:
dog
catfish
cow

Does there need to be some kind of encapsulation/delimiter of the capture group symbol or register symbol in the :s function for these to work as intended when next to each other?

A: \= must come at the start of the replacement part.
Wrong:
:s/cat/&\=@a                 <-- cat\=@a

Right:
:s/cat/\=submatch(0) . @a    <-- catfish

See :help s/\=.

A: You can use Ctrl+R to insert the content of a register.
:%s/cat/&<C-R>a/g

