vim, is it possible to search and replace content inside the register?

vim

Solution

Maybe something like this. Which is basically take the value in register a and send it through the substitute command and put it back into the register (with the correct register type)

:call setreg('a', substitute(getreg('a'), 'pat', 'sub', 'g'), getregtype('a'))

Or if you don't care about the regtype when you are done

:let @a=substitute(@a, 'pat', 'sub', 'g')

would be simplier.

Problem

For example, one of my registers "a has content "vim is awesome" and I want to replace awesome with "cool" inside the register "a BTW, I'm not looking using content of register as search/replacement pattern. I knew I can paste the content of register a in command mode with CTRL-R a

Original source