Surround editing
Development reference · View source
m s, m r, and m d add, replace, and delete the pair of quotes or
brackets around each selection, as in Helix. The keys after them name the
pairs.
| Keys | Action |
|---|---|
m s then a character | Surround each selection with that pair |
m r then two characters | Replace the surrounding pair named by the first with the pair named by the second |
m d then a character | Delete the surrounding pair |
Examples:
| Text and cursor | Keys | Result |
|---|---|---|
name with name selected | m s " | "name", selected with its quotes |
(a, b) with the cursor on b | m r ( [ | [a, b] |
say("hi") with the cursor on h | m d " | say(hi) |
[x, {y}] with the cursor on y | m d m | [x, y] |
word under the cursor | m i w m s * | *word* |
- Either bracket names its pair:
(and)both mean parentheses, as do[/],{/}, and</>. Any other character is used on both sides, som s *andm s |work. m randm dfind the pair asm adoes, from the character under each cursor: through the syntax tree first, then by a balanced scan of the text. They know the seven pairsm aknows,(,[,{,<,",', and`, andmfor the closest of any of them.- With a pair selected, as
m a (leaves it,m d (deletes that pair rather than the one outside it. m sselects the result, delimiters included.m randm dkeep the selection on the text it covered.- If any cursor has no surrounding pair, nothing changes and the status line says so. Cursors inside the same pair edit it once.
Esccancels while the keys are pending.