How to put quotes or brackets around a word in Vim
In plain Vim, put the cursor on the word, press ciw, type "", press Esc, then P to paste the word back between the quotes. With the vim-surround plugin, ysiw" does it in one command.

The menu page won't build. Someone filled in today's specials without quotes, so JavaScript reads Carnitas as the name of a variable and can't find one. Both values need a double quote at each end, and Vim has no single key for that.
special: Carnitas, special: "Carnitas",Quote the specials
The cursor is on today's special.
"", press Esc, then paste the word back with Pspecials.jsThis editor needs a keyboard. Read on, and play it at your computer.
Wrap a word in one command with vim-surround
Typing the quotes and pasting the word back gets old by the third time. Tim Pope's vim-surround plugin adds a verb for it. ys wraps text. After it comes what to wrap, named the way you'd name it after d or c, and then the character to wrap it in. So ysiw" reads as "wrap the inner word in double quotes", and the cursor can be anywhere in the word.
ys, cs and ds all come from that plugin, so plain Vim and Neovim only have them once you install it or something like it. VS Code's Vim extension and Zed's Vim mode have them built in, and IdeaVim needs one line in its config. The notes at the bottom of the page say how for each editor. The editor on this page runs them, so you can try them here whatever you use.
Tomorrow's specials
Same mistake, next day's file. This time, use the plugin.
This editor needs a keyboard. Read on, and play it at your computer.
Change the quotes, or take them off
Two more verbs come with the plugin. cs changes the pair around the cursor. You name the pair that's there now, then the one you want, so cs"' turns "Horchata" into 'Horchata'. ds deletes a pair and keeps what was inside, so ds" turns "3.50" back into 3.50. As with ci", the cursor can be anywhere inside the quotes.
The drinks list
The linter wants single quotes in this file, and a price in quotes is text, which won't add up at the till. The cursor is inside the drink's name.
This editor needs a keyboard. Read on, and play it at your computer.
Without the plugin, taking quotes off is a small trick of its own. di" cuts what's inside and leaves the cursor on the closing quote. v h selects that quote and the one before it, and p pastes the text over both.
price: "3.50", price: 3.50,Brackets, tags and more than one word
The character at the end of a ys goes on both sides, and a bracket brings its partner. Which bracket you type decides the spacing. A closing one wraps tightly, so ysiw) gives (word). An opening one adds a space inside each end, so ysiw( gives ( word ). Braces and square brackets work the same way.
For HTML, type a whole tag as the pair. ysiw<em> gives <em>word</em>, and with cs and ds the letter t stands for the tags around the cursor, so dst strips them off. yss wraps the whole line. For more than one word, select the words in Visual mode first, then press S and the character or tag.
New on the board
New items on the specials board go in italics. The cursor is on the first one.
This editor needs a keyboard. Read on, and play it at your computer.
| Keys | What it does |
|---|---|
ciw "" Esc P | quotes round the word under the cursor, in any Vim, no plugin (type () instead of "" for brackets) |
| di" v h p | takes the quotes off, no plugin |
| ysiw" | wraps the word in double quotes |
| ysiw) / ysiw( | (word) / ( word ), and the same for ] [ and } { |
| ysiw<em> | <em>word</em> |
| yss) | wraps the whole line, from its first character that isn't a space |
| S" (Visual mode) | wraps the selection |
| cs"' | changes the double quotes around the cursor to single quotes |
| ds" / ds) | takes off the quotes or brackets around the cursor and keeps the text |
| dst | takes off the HTML tags around the cursor |