Surrounds are another useful feature of Helix which allow you to perform common actions such as:
- Surround selection with character
- Replace surrounding character
- Delete surrounding character
You can use any character for a surround add, replace or delete operation -- such as x.
Some surround characters are more advanced. For example, having a selection and surrounding it with ( will add ( at the beginning of the selection and ) at the end.
Surround selection with character
You can surround selections with specific characters with ms for make surrounding. For example, with the whole hello word selected:
hello world
Pressing ms(, you surround the selection with (:
(hello) world
Replace surrounding character
But what if we actually meant to surround it with { instead? That's fine! We can make replace the surrounding character with mr
For instance, place your cursor anywhere in hello. mr({ replaces the surrounding ( with a {:
{hello} world
Delete surrounding character
If we wanted to delete the surrounding character, we could also use md for make delete. For example to delete the nearest surrounding pair of {, use md{.
hello world
List of surrounds
Helix has support for the following pairs of surrounds:
{and}(and)[and]<and>
Use any character
You can also use any other character which will act on the literal characters. With cursor on the w in world:
hello *world*
-
Pressing md* will delete the nearest
*.hello world -
Using mro{ will replace the nearest pairs of
ocharacter with a pair of{:hell{ *w}rld*