vimtricks.wiki Concise Vim tricks, one at a time.

How do I lowercase a word in Vim?

Answer

guiw

Explanation

The guiw command converts the entire word under the cursor to lowercase. It combines the gu operator (make lowercase) with the iw (inner word) text object.

How it works

  • gu is the lowercase operator
  • iw selects the inner word under the cursor
  • Together they lowercase every character in the word

Example

Given the text:

The QUICK Brown Fox

With the cursor on QUICK, pressing guiw results in:

The quick Brown Fox

Tips

  • Use gUiw to convert a word to UPPERCASE instead
  • Use g~iw to toggle the case of each character in the word
  • Use guu or gugu to lowercase the entire current line
  • Use gUU or gUgU to uppercase the entire current line
  • In visual mode, select text and press u to lowercase or U to uppercase
  • Works with any text object or motion: guap to lowercase a paragraph, gu$ to lowercase to end of line

Next

How do I edit multiple lines at once using multiple cursors in Vim?