For instance, let's say I want to change all instances of Ctrl-m, Ctrl-p, etc., in a document to the more conventional ^M, ^P, etc. I can use :s/Ctrl-\(.\)/^\1to almost accomplish this, but it leaves the letters in lowercase where they should be in uppercase.

How can I change the case of a backreferenced regex match in a Ex-mode substitute command? (:s)

1 Answer 1


Perhaps like this:


For more information: :help s/\u.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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