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
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s