In VIM, it's really easy to change a word of text to use uppercase or lowercase:
# in visual mode
# change word to uppercase
gUw
# change word to lowercase
guw
Is there a simple way to modify the word to use initial caps?
You can change the case of text: Toggle case " HellO " to " hELLo " with g~ then a movement. Uppercase " HellO " to " HELLO " with gU then a movement. Lowercase " HellO " to " hello " with gu then a movement.
Switch case You can switch the case of the alpha character underneath your cursor in vi the tilde key ( ~ ). Doing so shifts from lowercase to uppercase and vice versa.
Change case Select the text for which you want to change the case. Go to Home > Change case . Do one of the following: To capitalize the first letter of a sentence and leave all other letters as lowercase, click Sentence case.
You can use * and/or # to search for the word under the cursor or viw to visually select the word under the cursor.
Assuming cursor is at the beginning of the word, use
gUl
(if the word was all-lowercase) or
gUllgue
to explicitly make the first letter capital and other lower case.
It's the same that you used, only instead of w
(word motion) you use l
(one symbol motion).
If the cursor is somewhere in the middle of the word, prepend b
(go to the beginning of the word) to the commands above.
You can map some key to do this if you use it often.
I'd suggest moving to the beginning of the word with whatever motion command(s) you want, then pressing ~. This behavior is affected by the tildeop
option, see :help ~
and :help tildeop
for more info.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With