We have a 5000-line text file containing words like so:
BANKS
BEING AFRAID OF DOGS
This is a SENTENCE.
Just another sentence.
COUNTRY
Using vim
, I want to capitalize the words only in the lines where all the words are in uppercase (meaning lines 3 and 4 should be left untouched). In other words, what I expect to get is:
Banks
Being Afraid Of Dogs
This is a SENTENCE.
Just another sentence.
Country
By referring to Power of g and Switching_case_of_characters.
g/^[A-Z ]*$/
s/\<\(\w\)\(\w*\)\>/\u\1\L\2/g
The whole command will be
:g/^[A-Z ]*$/s/\<\(\w\)\(\w*\)\>/\u\1\L\2/g