-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
3. Tutorial: Surround
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.
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
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
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
Helix has support for the following pairs of surrounds:
-
{
and}
-
(
and)
-
[
and]
-
<
and>
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
o
character with a pair of{
:
hell{ w}rld
With multiple cursors, macros, text objects and finally surround you now have all of the most important tools for efficiently working with text.
Let's learn how to configure editor tooling next, with setting up language support.