:s/\<./\u&/g
(You might be wondering why we didn't use
:s/\<[a-z]/\u&/g to match lowercase
letters. The <. actually matches the first
character of every word, but the
\u will only affect letters. So, unless you only
want to capitalize certain letters, <. is
enough.)
The previous example does only the current line. You can add a range
of lines after the colon. For example, to edit all lines in the file,
type the following:
:%s/\<./\u&/g
To do the current line and the next five, use this:
:.,+5s/\<./\u&/g
To make the first character of each word uppercase (with
\u) and the rest lowercase (with
\L), try:
Those commands can be a pain to type. If you use one of them a lot,
try putting it in a keymap (Section 18.2).