Use case: I've just entered insert mode, and typed some text. Now I want to make it uppercase.
It can be done via gUmotion
. However, I can't find the motion over the text entered in the recent input session. It's somewhat strange and the concept of such motion is buggy (where to move if you've deleted text, for example?), but it may solve my problem.
Or, are there other ways of making uppercase the text you've recently inputted?
Visual select the text, then U for uppercase or u for lowercase. To swap all casing in a visual selection, press ~ (tilde). Without using a visual selection, gU<motion> will make the characters in motion uppercase, or use gu<motion> for lowercase.
To use a keyboard shortcut to change between lowercase, UPPERCASE, and Capitalize Each Word, select the text and press SHIFT + F3 until the case you want is applied.
First press v or V then move to select text. If you don't select text, pressing U will undo all changes to the current line. Change the current line to uppercase (same as VU ). Change current word to uppercase.
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.
The motion you're looking for is:
`[
(backtick, open-square-bracket). To do a simple motion, you'd use:
gU`[
However, you'll find that the last character probably won't be included due to the way the motion works (I could be wrong). A simple solution would then be to do:
v`[U
Which is to say "go to visual mode, select from the current position to the start of the last changed text, make it upper case". For more information, see:
:help '[ :help mark-motions
Note the difference in :help mark-motions
between a backtick and a single-quote.
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