Searching /<pattern> in a document highlights text in some places like this:

some text ...
match1 some text ...
some text match2
match3 text match4

Is there a way to make all the matches uppercase with :%s//<something>/g? I currenty do this kind of things by using the gn operator, but I would like to know a better way.

  • 1
    :%s/match. some text/\U&/g
    – Maxim Kim
    Dec 4, 2021 at 18:21

1 Answer 1


check :h :s% for substitute options, including:

      \U      following characters made uppercase, until \E      *s/\U*



will replace all word to WORD.

  • If you are using % do you need to use g as well?
    – user25109
    Dec 5, 2021 at 15:40
  • 1
    @elmclose depends on what you need. /g will replace all matches in a given :s range. All matches in a single line, all matches in all range lines...
    – Maxim Kim
    Dec 5, 2021 at 15:50
  • @elmclose not really. Consider word word and try to change :%s/word/hello
    – Maxim Kim
    Dec 5, 2021 at 17:43

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.