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
guis the lowercase operatoriwselects 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
gUiwto convert a word to UPPERCASE instead - Use
g~iwto toggle the case of each character in the word - Use
guuorguguto lowercase the entire current line - Use
gUUorgUgUto uppercase the entire current line - In visual mode, select text and press
uto lowercase orUto uppercase - Works with any text object or motion:
guapto lowercase a paragraph,gu$to lowercase to end of line