How to change letters in a word from upper case to lower case or the other way around (swap case)?
It's
g~iw
with the cursor on the word.
Key:
g
flag (I couldn't find a good reference for this...)~
toggle case; alternatively useU
for to-upper oru
for to-loweriw
selects the Inner Word, i.e. the word that the cursor is on;ip
selects the Inner Paragraph
See Michael Jakl's Vim Introduction and Tutorial - concise and has some nice graphical explanations.
g~
followed by a "motion" will flip the case of the letters.
gU
will upper-case them
gu
will lower case them
So
g~w
will flip the case of the letters to the end of the current word.
guG
will lower case the letters to the end of the file
gU$
will upper case the letters to the end of the current line.
you can do this in normal mode: vEU
(having the cursor at the beginning of the word or pressing b
to move it there)
v
- go to visual
E
- go to end of the word
U
- make the visual selection uppercase
Instead of the U
you can do u
for lowercase or ~
for case flip.