Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change letters in a word from upper case to lower case or the other way around (swap case)?

Tags:

vim

Instead of deleting the word and retyping all the letters once again in the opposite case, I'd like to find some smart way in Vim to solve the problem.

like image 820
Haiyuan Zhang Avatar asked Feb 17 '10 23:02

Haiyuan Zhang


People also ask

How do I change all caps to lowercase automatically?

Move to the Font group on the HOME tab and click on the Change Case icon. Pick one of 5 case options from the drop-down list. Note: You can also select your text and press Shift + F3 until the style you want is applied. Using the keyboard shortcut you can choose only upper, lower or sentence case.

How can I change my case while typing?

While typing, you can modify the case of any text by pressing either the Caps Lock or Shift .


1 Answers

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 use U for to-upper or u for to-lower
  • iw 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.

like image 156
martin clayton Avatar answered Oct 23 '22 13:10

martin clayton