vim Manipulating text Converting text case


Example

In normal mode:

  • ~ inverts the case of the character under the cursor,
  • gu{motion} lowercases the text covered by {motion},
  • gU{motion} uppercases the text covered by {motion}

Example (^ marks the cursor position):

Lorem ipsum dolor sit amet.
        ^
Lorem ipSum dolor sit amet.    ~
Lorem IPSUM DOLOR sit amet.    gU2w
Lorem IPsum DOLOR sit amet.    gue

In visual mode:

  • ~ inverts the case of the selected text,
  • u lowercases the selected text,
  • U uppercases the selected text

Example (^^^ marks the visual selection):

Lorem ipsum dolor sit amet.
        ^^^^^^^^^^^^^
Lorem ipSUM DOLOR SIT amet.    ~
Lorem ipSUM DOLOR SIT amet.    U
Lorem ipsum dolor sit amet.    u