How do I quickly change surrounding quotes, brackets, or tags in Vim?
cs"'
The vim-surround plugin by Tim Pope lets you change any surrounding delimiter pair with a single cs command.
plugins #plugins #surround #editing #text-objects #normal-mode
cs"'
The vim-surround plugin by Tim Pope lets you change any surrounding delimiter pair with a single cs command.
plugins #plugins #surround #editing #text-objects #normal-mode
ds"
The vim-surround plugin provides the ds command to instantly delete any surrounding delimiter pair.
plugins #plugins #surround #editing #text-objects #normal-mode
ysiw)
The vim-surround plugin provides the ys (you surround) operator to wrap any Vim text object or motion with a delimiter pair.
plugins #plugins #surround #editing #text-objects #normal-mode
cx{motion}
The vim-exchange plugin by Tom McDonald provides the cx operator to swap two arbitrary text regions.
plugins #plugins #exchange #editing #text-objects #refactoring
ciw""<Esc>P
Vim doesn't have a built-in "surround" operator, but you can wrap any word in quotes or brackets with a short sequence: ciw""P.
editing #editing #text-objects #normal-mode #productivity #surround
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.
v + repeated iw/aw/i(/a(/ip/ap
Once you enter visual mode, you can progressively expand your selection by typing increasingly larger text objects.
visual-mode #visual-mode #text-objects #editing #selection #productivity
dap / dip
The dap and dip commands use Vim's paragraph text objects to delete an entire block of contiguous text in a single motion.
editing #editing #text-objects #normal-mode #delete #motions
di(
The di( command deletes everything inside the nearest pair of parentheses without removing the parentheses themselves.
cit
The cit command deletes everything between the nearest pair of HTML/XML tags and drops you into insert mode, ready to type the replacement.
ci"
The ci" command deletes everything inside the nearest pair of double quotes and drops you into insert mode, ready to type the replacement.
cis
The cis command deletes the entire sentence under the cursor and drops you into insert mode, ready to type a replacement.
ct{char}
The ct{char} command deletes everything from the cursor up to (but not including) the specified character and drops you into insert mode.
editing #editing #motions #normal-mode #text-objects #productivity
cw vs ciw
The cw and ciw commands both change a word, but they behave differently depending on cursor position.
editing #editing #text-objects #motions #normal-mode #productivity
gUiw
The gUiw command converts the entire word under the cursor to uppercase.
vat
The vat command visually selects the nearest enclosing HTML or XML tag and all of its contents, including the opening and closing tags themselves.
visual-mode #visual-mode #text-objects #editing #normal-mode
vi{
The vi{ command visually selects everything inside the nearest pair of curly braces {}, without selecting the braces themselves.
visual-mode #visual-mode #text-objects #editing #normal-mode
vip
The vip command visually selects the inner paragraph — all contiguous non-blank lines surrounding the cursor.
visual-mode #visual-mode #text-objects #editing #normal-mode
gqip
The gqip command reformats the current paragraph to fit within the configured textwidth.
guiw
The guiw command converts the entire word under the cursor to lowercase.