0

I want to copy something to a register or more ideally the system clipboard and then run a search / replace regex on it the way that I do in the buffer...is that possible?

3

Assume you copied the following line to the register +:

Copied to clipboard.

Now you want to replace "clipboard" with "register" inside the register +:

:let @+=substitute(@+, 'clipboard', 'register', 'g')

The @+ represents the register +, @@ is the unnamed register, @a is register a,... . See :help :let-@.

And substitute(...) is processing a string (here from reg +) like :s/clipboard/register/g would process the line in the file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.