Vim Tips Wiki

Editing

Switching case of characters

1
  • The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit. If you are undoing an edit that is …
Latest revision Your text
Line 18: Line 18:
 
Alternatively, you can visually select text then press <code>~</code> to toggle case, or <code>U</code> to convert to uppercase, or <code>u</code> to convert to lowercase.
 
Alternatively, you can visually select text then press <code>~</code> to toggle case, or <code>U</code> to convert to uppercase, or <code>u</code> to convert to lowercase.
   
==Examples==
+
fdsfsdfsdfasdf
 
; <code>~</code>
 
: Toggle case of the character under the cursor, or all visually-selected characters.
 
 
; <code>3~</code>
 
: Toggle case of the next three characters.
 
 
; <code>g~3w</code>
 
: Toggle case of the next three words.
 
 
; <code>g~iw</code>
 
: Toggle case of the current word (inner word &ndash; cursor anywhere in word).
 
 
; <code>g~$</code>
 
: Toggle case of all characters to end of line.
 
 
; <code>g~~</code>
 
: Toggle case of the current line (same as <code>V~</code>).
 
 
The above uses ~ to toggle case. In each example, you can replace ~ with u to convert to lowercase, or with U to convert to uppercase. For example:
 
 
; <code>U</code>
 
: Uppercase the visually-selected text.
 
: First press <code>v</code> or <code>V</code> then move to select text.
 
: If you don't select text, pressing <code>U</code> will undo all changes to the current line.
 
 
; <code>gUU</code>
 
: Change the current line to uppercase (same as <code>VU</code>).
 
 
; <code>gUiw</code>
 
: Change current word to uppercase.
 
 
; <code>u</code>
 
: Lowercase the visually-selected text.
 
: If you don't select text, pressing <code>u</code> will undo the last change.
 
 
; <code>guu</code>
 
: Change the current line to lowercase (same as <code>Vu</code>).
 
   
 
==Title case==
 
==Title case==
  Loading editor
Below are some commonly used wiki markup codes. Simply click on what you want to use and it will appear in the edit box above.

View this template