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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With