Thursday, August 28, 2008

Uppercase, Lowercse, Swapcase

In Vim, you can use the following motions to modify the case of an entity.


gum - lowercase text operated on by motion
gUm - uppercase text operated on by motion
g~m - switch case operated on by motion
~ - if notildeop is set (default), switch case under cursor
~ - if tildeop is set, switch case of {motion} text


Examples:


guw - lowercase current word
gU$ - uppercase to end of line
g~w - swapcase current word
v$~ - swapcase to end of line (if notildeop is set)
~w - swapcase of word (if tiildeop is set)

2 comments:

Max Cantor said...

This works with vim's (i)nner/(a)mbient gestures, so if your cursor is at "foob|ar" and you type gUiw, you will end up with "FOOB|AR".

Travis Whitton said...

Good stuff! Thanks for the tip.