Answer
:%s/\v<(\w)(\w*)>/\u\1\L\2/g
Explanation
When you need to normalize casing across headings, labels, or generated docs, editing words one by one is tedious. This substitution converts each word to title case in a single pass: first letter uppercase, remainder lowercase. It is a practical cleanup step after importing noisy text from external tools.
How it works
:%s/\v<(\w)(\w*)>/\u\1\L\2/g:%stargets the whole buffer\venables very-magic regex syntax<(\w)(\w*)>matches each word boundary and splits the word into first character plus remainder\u\1uppercases capture group 1 (the first letter)\L\2lowercases capture group 2 (the rest of the word)gapplies this to every word occurrence on each line
Example
Before:
ERROR LEVEL summary
second LINE OF TEXT
After:
Error Level Summary
Second Line Of Text
Tips
- To avoid touching short acronyms, run with
cand confirm selectively - Restrict the range (for example
:10,40s/...) when you only want part of a file normalized - Combine with marks so you can jump back to your original editing location quickly
category: editing tags: #editing #substitution #regex #formatting
Next
How do I uppercase text inside an HTML tag without changing the tags?
Related Tricks
How do I normalize curly quotes to straight quotes in the current buffer?
:%s/[“”]/"/ge<CR>:%s/[‘’]/'/ge<CR>
How do I join a wrapped paragraph into one line without manual cursor moves?
vipJ
How do I collapse long runs of blank lines to a single empty line?
:%s/\n\{3,}/\r\r/g
How do I join wrapped paragraph lines while keeping blank-line paragraph separators?
:g/^\s*$/,/./-1join
How do I swap the first two comma-separated fields on each line with one substitute command?
:%s/\v^([^,]+),([^,]+),/\2,\1,/<CR>
