You can use the following commands to change the case of characters:

  • ~ invert the case of the character under the cursor (i.e. lowercase becomes UPPERCASE and vice versa)
  • g~ followed by motion inverts the case of those characters
    • for example: g~e, g~$, g~iw, etc
  • gu followed by motion changes those characters to lowercase
    • for example: gue, gu$, guiw, etc
  • gU followed by motion changes those characters to UPPERCASE
    • for example: gUe, gU$, gUiw, etc

info You can also provide a count prefix to these commands. For example, 3~ will invert the case of the current character and two characters to the right.

Video demo:


info See also my Vim Reference Guide and curated list of resources for Vim.