Surround: add, replace and delete pairs
So far match mode has only selected. It also edits — specifically, it edits the pairs themselves. Three commands cover it, and each one takes the pair character as its last key:
ms— surround the current selection with a pair:ms"wraps it in double quotes,ms(in parentheses, and so onmr— replace the closest surrounding pair with another:mr"'turns"text"into'text'md— delete the closest surrounding pair, keeping what was inside:md(turns(text)intotext
ms works on whatever is selected, so pair it with a selection first — miw
to wrap a word, x to wrap a line, or any selection from the last few steps.
mr and md don’t need a selection at all; they look outward from the
cursor for the pair you name, so the cursor just needs to be somewhere inside
it.
In most editors, changing a string’s quote style means deleting and retyping at both ends. Here it’s three keys.
Try it in the editor. Each line below wants a different surround command — work through the checklist.