Skip to content

3. Tutorial: Surround

Nik Revenco edited this page Mar 1, 2025 · 2 revisions

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 having a selecting and surrounding it with ( with 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*
  1. Pressing md* will delete the nearest *.
hello world
  1. Using mro{ will replace the nearest pairs of o character with a pair of {:
hell{ w}rld