vim convert to lowercase or uppercase

 

By using simple substitution we can convert  text in vim either to lowercase or to uppercase.

I have a following text in in one of file:

aBcDeFgH
iJkLmNoP
qRsTuVwX
yZ

To convert complete text to uppercase use following substitution code:

:%s/.*/\U&/g

or

:%s/[a-z]/\U&/g

Similarly to convert complete text to lowercase use substitution code:

:%s/.*/\L&/g

or

:%s/[A-Z]/\L&/g

Leave a comment