vim: Surround in visual mode (#13347)

Adds support for surrounding text in visual/visual-line/visual-block
mode by re-using the `AddSurrounds` operator. There is no default
binding though so the user must follow the instructions to enable it.

Note that the behaviour varies slightly for the visual-line and
visual-block modes. In visual-line mode the surrounds are placed on
separate lines (the vim-surround extension also indents the contents but
I opted not to as that behaviour is less important with the use of code
formatters). In visual-block mode each of the selected regions is
surrounded and the cursor returns to the beginning of the selection
after the action is complete.

Release Notes:

- Added action to surround text in visual mode (no default binding).

Fixes #13122
This commit is contained in:
Benjamin Davies 2024-06-25 03:29:06 +12:00 committed by GitHub
parent 5a8c2a4a88
commit 77b2da2b42
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 167 additions and 9 deletions

View file

@ -293,6 +293,22 @@ Subword motion is not enabled by default. To enable it, add these bindings to yo
},
```
Surrounding the selection in visual mode is also not enabled by default (`shift-s` normally behaves like `c`). To enable it, add the following to your keymap.
```json
{
"context": "Editor && vim_mode == visual && !VimWaiting && !VimObject",
"bindings": {
"shift-s": [
"vim::PushOperator",
{
"AddSurrounds": {}
}
]
}
}
```
## Supported plugins
Zed has nascent support for some Vim plugins: