Friday 10 February 2012

Upper and lower case in vim

I use vim for most of my text editing, especially with it comes to configuration and text files on UNIX / Linux machines, and there are times where I need to convert the entire file to uppercase or to lowercase. I find these two commands useful (when in command mode of vim):

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

converts all uppercase characters to lowercase,

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

converts all lowercase characters to uppercase.

You could always toggle case characters using "~" as well.

No comments:

Post a Comment