Vi(m) tip #3: convert document to lowercase or uppercase

Alec Jacobson

October 16, 2009

weblog/

Convert every matching regex (or line) to lowercase or uppercase using vims gsub command. In normal mode this will convert the entire document to lowercase (ie downcase all capitals):
:%s/[A-Z]/\L&/g
Likewise for to upcase:
:%s/[a-z]/\U&/g
source