sponsor Vim development Vim logo Vim Book Ad

basic Tip #49: Switching case of characters

 tip karma   Rating 103/52, Viewed by 3394 

Read and edit this tip on the Vim tip wiki. The wiki may have a more recent version of this tip.

created:   March 14, 2001 9:24      complexity:   basic
author:   Anonymous      as of Vim:   5.7

To switch the case of one or more characters use the "~", "gU" or
"gu" commands.

Examples:

~     -     switch case of character under cursor
            (in visual-mode: switch case of highlighted text)

3~    -     switch case of next three characters

g~~   -     switch case of current line

U     -     in visual-mode: make highlighted text uppercase

gUU   -     make current line uppercase

u     -     in visual-mode: make highlighted text lowercase

guu   -     make current line lowercase

gUaw  -     make current word uppercase

guaw  -     make current word lowercase

For some more examples refer to

:help ~

See also:

:help simple-change

 rate this tip  Life Changing Helpful Unfulfilling 

<< Moving around | Recovering files >>

Additional Notes

[email protected], May 7, 2002 6:40
Not exactly case related but something I really like.

g?  does rot13 "encryption"
[email protected], July 8, 2003 4:25
Instead of g~~, i prefer V~
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
SourceForge.net Logo