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.

About these ads

2 Responses to “Note to self: Title Case in vim”


  1. 1 Celsius1414 2011/03/07 at 9:32 AM

    Bonus tip: record a macro to do this with a single key combo.

  2. 2 Tim 2011/03/18 at 5:05 AM

    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.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




Welcome!



Visit the Wiki!

Some recent desktops


May 6, 2011
Musca 0.9.24 on Crux Linux
150Mhz Pentium 96Mb 8Gb CF
 


May 14, 2011
IceWM 1.2.37 and Arch Linux
L2300 core duo 3Gb 320Gb

Some recent games


Apr. 21, 2011
Oolite on Xubuntu 11.04
L2300 core duo 3Gb 320Gb

Enter your email address to subscribe to this blog and receive notifications of new posts.

Join 405 other followers

License

This work is licensed under the GNU Free Documentation License. Please see the About page for details.

Blog Stats

  • 3,963,764 hits

Archives


Follow

Get every new post delivered to your Inbox.

Join 405 other followers

%d bloggers like this: