How do I uppercase a word in Vim?
Answer
gUiw
Explanation
The gUiw command converts the entire word under the cursor to uppercase. It combines the gU operator (make uppercase) with the iw (inner word) text object.
How it works
gUtriggers the uppercase operatoriwselects the inner word under the cursor
Example
Given the text with the cursor on hello:
say hello to vim
Pressing gUiw results in:
say HELLO to vim
The word hello is converted to HELLO. The cursor can be anywhere on the word.
Tips
- Use
guiwto convert a word to lowercase instead - Use
g~iwto toggle the case of each character in the word - Use
gUUorgU_to uppercase the entire current line - Use
gUapto uppercase an entire paragraph - In visual mode, select text and press
Uto uppercase oruto lowercase - Use
~to toggle the case of the single character under the cursor and advance