How do I invert the case of an entire paragraph with one operator command?
g~ap
g~ap is a fast way to invert letter case across a full paragraph without entering Visual mode.
editing #editing #operators #text-objects #case #normal-mode
g~ap
g~ap is a fast way to invert letter case across a full paragraph without entering Visual mode.
editing #editing #operators #text-objects #case #normal-mode
:%s/\v(\w+)/\u\L\1/g
Vim's substitution engine supports case-modifier sequences in the replacement string, making it possible to convert text to title case in a single command.
search #search #substitution #regex #editing #case #formatting
\C in search pattern
Adding \C anywhere in a search pattern forces case-sensitive matching for that search, overriding the global ignorecase setting.
<C-v>{motion}~
Visual block mode () selects a rectangular column region, and pressing ~ at the end toggles the case of every character in that exact column range across all se
\c
Vim lets you embed \c or \C directly inside a search pattern to control case sensitivity for that search only, regardless of your 'ignorecase' and 'smartcase' s
:%s/\v(old)/\=toupper(submatch(0)[0]).tolower(submatch(0)[1:])/g
Standard substitutions don't preserve the original case of matched text.
set ignorecase smartcase
Use ignorecase for case-insensitive search.
:let @a = toupper(@a)
Use Vimscript functions toupper() or tolower() with :let @a = toupper(@a) to convert the case of the entire register contents.
gU{motion} / gu{motion} / g~{motion}
Vim has three case operators that work with any motion or text object: gU for uppercase, gu for lowercase, and g~ for toggle case.
editing #editing #case #operators #text-objects #normal-mode
g~iw
The g~iw command toggles the case of every character in the word under the cursor — uppercase letters become lowercase and vice versa.