How to change letters in a word from upper case to lower case or vice versa (case of change)?

Instead of deleting the word and typing all the letters again in another case, I would like to find some smart way in Vim to solve the problem.

+41
vim
Feb 17 '10 at 23:31
source share
7 answers

it

g~iw 

using the cursor on the word.

Key:

  • g flag (I could not find a good link for this ...)
  • ~ switch key; alternatively use U for the top or U for the bottom
  • iw selects the Inner Word, that is, the word in which the cursor is located; ip selects the internal paragraph

See Michael Jakl's Introduction and Vim Tutorial - concise and have nice graphical explanations.

+70
Feb 17 '10 at 23:34
source share

you can do this in normal mode: vEU (with the cursor at the beginning of a word or pressing b to move it there)

v - go to visual

E - go to the end of the word

U - make a visual selection in uppercase

Instead of U you can make U for lowercase or ~ for a flip flag.

+26
Feb 17 '10 at 23:37
source share

g~ followed by "movement" will flip the case of letters.

gU will contain uppercase

gU will reduce their number

So,

g~w will flip the case of letters to the end of the current word.

guG will reduce the letter case to the end of the file

gU$ will contain upper case letters at the end of the current line.

+23
Feb 18 '10 at 0:13
source share

You can select a word with visual mode ( viw ) and press ~ , it will switch case for all letters in the word.

+7
Feb 17 '10 at 23:34
source share

~ (tilde). The case under the cursor should change. It works in normal and visual modes.

+6
Feb 17 '10 at 23:34
source share

I would like to emphasize that to achieve upper / lower case switching, it depends on what the exact cursor position is.

, if the cursor is now at the first character of the word,, you can use g~w :

g means you want to perform some operation in some area (while w definese is the exact area; ~ means you want to switch upper and lower case (you can substitute ~ with U / U , which means that you want to switch the word to uppercase / lowercase); w means that you want to make the case switch from the cursor to the end of the word;

, if the cursor is now in the middle of the word, and not at the very beginning , you can use g~iw :

iw means you want to do a random swith for the word the corsor is now in.

+1
Sep 23 '16 at 1:37
source share

Shift + F3 flips the word (s) between all uppercase letters, only the first letter and all lowercase letters. Changed my life

-one
May 11 '15 at
source share



All Articles