Zed Vim Key Mappings: Surrounds
Zed’s Vim mode includes a powerful “surround” feature, similar to the popular vim-surround plugin. This allows you to easily add, change, and delete surrounding characters like parentheses, brackets, quotes, and HTML tags.
The primary commands are:
y s(Yank Surround): Add surrounds to a text object.d s(Delete Surround): Delete a surrounding pair.c s(Change Surround): Change one surrounding pair for another.
Examples
| Command | Action | Before | After |
|---|---|---|---|
ysiw" | Add double quotes around a word | word | "word" |
ds" | Delete surrounding double quotes | "word" | word |
cs"' | Change surrounding double quotes to single quotes | "word" | 'word' |
ysiw<em> | Add <em> tags around a word | word | <em>word</em> |
cst<p> | Change surrounding tags to <p> tags | <em>word</em> | <p>word</p> |
Key Mappings
| Operator | Key | Action |
|---|---|---|
ys | ) or b | Add () |
ys | ] or [ | Add [] |
ys | } or { or B | Add {} |
ys | > or < | Add <> |
ys | t | Add tags |
ds / cs | ) or b | For () |
ds / cs | ] or [ | For [] |
ds / cs | } or { or B | For {} |
ds / cs | > or < | For <> |
ds / cs | t | For tags |