Convert to Uppercase or Lowercase in vi

The other day I have copied a load of statements (SQL) that I was putting into a script.  I have some strange OCD weirdness and like all the SQL scripts to be formatted a certain way, keywords in UPPERCASE things like that.

Now for all the index rebuilds the majority of the line should be upper case like

ALTER INDEX schmea.name REBUILD ONLINE;

All the lines where all lower case, I could of used several different statements to make the words go uppercase, but I decided to just make those certain lines all uppercase.  To this this use the commands below, in this example everything from line 21 to 28 will be converted into uppercase.

:21,28s/.*/\U&/

You can if you want to change everything into Upper case, to do that

:%s/.*/\U&/

If you want to convert everything to lowercase then all you need to do is change the U for an L.

I am always interested in feedback so please feel free to add any comments, or you can mail me  here.  If you would like to submit a quick tip  with full credit and links back to your site then also feel free to contact me.

Related Posts Plugin for WordPress, Blogger...

My Card in Contacts shows someone elses details

Reduce jpg size using preview

Reduce jpg size using preview