Note to self: Title Case in vim

Strictly as a note to myself, because I’ll never remember this on its own …

:s/\<\(\w\)\(\w*\)\>/\u\1\L\2/g

That will convert a line of text to Title Case in vim, either on the line it’s issued or over selected blocks.

vim has single-key case conversion anyway (the tilde key) but this might be the quickest way to arbitrarily switch everything to title case.

Not my discovery or idea; found by way of the Vim Tips Wiki.

2 thoughts on “Note to self: Title Case in vim

  1. Tim

    To be honest, I’d rather just do: ~w.w.w.w.w.w.w […]

    It’s easier for me to mash the w and . keys than it is to find and copy in that regex monstrosity.

    Reply

Leave a comment