<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>book/src/surround.md - fork/helix @ 25.01</title>
<meta name="description" content="book/src/surround.md in fork/helix at 25.01.">
<meta property="og:title" content="book/src/surround.md - fork/helix @ 25.01">
<meta property="og:description" content="book/src/surround.md in fork/helix at 25.01.">
<meta property="og:type" content="website">
<meta property="og:site_name" content="git.julia.blue">
<link rel="stylesheet" href="/css/style.css?v=62">
<script type="module" src="/js/main.js?v=62"></script>
</head>
<body>
<main data-ref="25.01" data-tip="dabfb6ceeae1da57fb93efcd254e917db49655e6">
<noscript>
  <div class="callout">
    <p>
      hey! this is a static git repo viewer. commit diffs, file history,
      older commits and other revisions won't load without javascript.
    </p>
    <p>
      you are still able to view source files on branch/tag tips,
      but the experience is degraded.
    </p>
  </div>
</noscript>
<header class="repo"><div>
<h1>fork/helix</h1>
</div>
<pre class="clone">git clone https://git.julia.blue/fork/helix</pre>
</header>
<p class="snapshot-commit"><span class="commit-author">David Else</span><span class="commit-message" data-commit="a959c0ef9be59e63617c8e95d1ac59889d45a8b5">Improve the structure of the documentation (#10619)</span><span class="snapshot-sha sha" data-commit="a959c0ef9be59e63617c8e95d1ac59889d45a8b5">a959c0ef</span><time datetime="2024-05-06T16:39:06+01:00" title="2024-05-06 16:39:06 +0100">2024-05-06</time></p>
<header class="topbar"><details class="switcher"><summary>25.01</summary><div class="menu"><strong>branches</strong><a href="/fork/helix/ref/master/">master</a><strong>tags</strong><a href="/fork/helix/ref/23.05/">23.05</a><a href="/fork/helix/ref/23.10/">23.10</a><a href="/fork/helix/ref/24.03/">24.03</a><a href="/fork/helix/ref/24.07/">24.07</a><a class="current" href="/fork/helix/ref/25.01/">25.01</a><a href="/fork/helix/ref/25.01.1/">25.01.1</a><a href="/fork/helix/ref/25.07/">25.07</a><a href="/fork/helix/ref/25.07.1/">25.07.1</a><a class="all" href="/fork/helix/refs">all refs →</a></div></details><nav class="crumbs"><a href="/fork/helix/">helix</a> / <a href="/fork/helix/ref/25.01/tree/book/">book</a> / <a href="/fork/helix/ref/25.01/tree/book/src/">src</a> / <span class="cur">surround.md</span></nav>
<span class="view-stats"><span>1.1 KiB</span><span>24 lines</span></span><span class="actions"><a class="raw" href="/fork/helix/raw/187d2876a4c31f9d5e9ea3e84d61bc53ce344dfa/book/src/surround.md">raw</a></span></header>
<div class="markdown-view"><input type="radio" name="markdown-view" id="markdown-rendered" checked><label for="markdown-rendered">rendered</label><input type="radio" name="markdown-view" id="markdown-code"><label for="markdown-code">code</label><section class="readme rendered"><h2>Surround</h2>
<p>Helix includes built-in functionality similar to <a href="https://github.com/tpope/vim-surround">vim-surround</a>.
The keymappings have been inspired from <a href="https://github.com/machakann/vim-sandwich">vim-sandwich</a>:</p>
<p><img src="https://user-images.githubusercontent.com/23398472/122865801-97073180-d344-11eb-8142-8f43809982c6.gif" alt="Surround demo" /></p>
<table><thead><tr><th>Key Sequence</th><th>Action</th></tr></thead><tbody>
<tr><td><code>ms&lt;char&gt;</code> (after selecting text)</td><td>Add surround characters to selection</td></tr>
<tr><td><code>mr&lt;char_to_replace&gt;&lt;new_char&gt;</code></td><td>Replace the closest surround characters</td></tr>
<tr><td><code>md&lt;char_to_delete&gt;</code></td><td>Delete the closest surround characters</td></tr>
</tbody></table>
<p>You can use counts to act on outer pairs.</p>
<p>Surround can also act on multiple selections. For example, to change every occurrence of <code>(use)</code> to <code>[use]</code>:</p>
<ol>
<li><code>%</code> to select the whole file</li>
<li><code>s</code> to split the selections on a search term</li>
<li>Input <code>use</code> and hit Enter</li>
<li><code>mr([</code> to replace the parentheses with square brackets</li>
</ol>
<p>Multiple characters are currently not supported, but planned for future release.</p>
</section><div class="code-panel"><pre class="code src language-markdown"><span class="code-line"><a class="ln" id="L1" href="#L1">1</a><span class="code-text"><a-p>##</a-p> <a-tt>Surround</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L2" href="#L2">2</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L3" href="#L3">3</a><span class="code-text">Helix includes built-in functionality similar to [vim-surround](https://github.com/tpope/vim-surround).</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L4" href="#L4">4</a><span class="code-text">The keymappings have been inspired from [vim-sandwich](https://github.com/machakann/vim-sandwich):</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L5" href="#L5">5</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L6" href="#L6">6</a><span class="code-text">![Surround demo](https://user-images.githubusercontent.com/23398472/122865801-97073180-d344-11eb-8142-8f43809982c6.gif)</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L7" href="#L7">7</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L8" href="#L8">8</a><span class="code-text">| Key Sequence                      | Action                                  |</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L9" href="#L9">9</a><span class="code-text">| --------------------------------- | --------------------------------------- |</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L10" href="#L10">10</a><span class="code-text">| `ms&lt;char&gt;` (after selecting text) | Add surround characters to selection    |</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L11" href="#L11">11</a><span class="code-text">| `mr&lt;char_to_replace&gt;&lt;new_char&gt;`   | Replace the closest surround characters |</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L12" href="#L12">12</a><span class="code-text">| `md&lt;char_to_delete&gt;`              | Delete the closest surround characters  |</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L13" href="#L13">13</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L14" href="#L14">14</a><span class="code-text">You can use counts to act on outer pairs.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L15" href="#L15">15</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L16" href="#L16">16</a><span class="code-text">Surround can also act on multiple selections. For example, to change every occurrence of `(use)` to `[use]`:</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L17" href="#L17">17</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L18" href="#L18">18</a><span class="code-text"><a-p>1. </a-p>`%` to select the whole file</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L19" href="#L19">19</a><span class="code-text"><a-p>2. </a-p>`s` to split the selections on a search term</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L20" href="#L20">20</a><span class="code-text"><a-p>3. </a-p>Input `use` and hit Enter</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L21" href="#L21">21</a><span class="code-text"><a-p>4. </a-p>`mr([` to replace the parentheses with square brackets</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L22" href="#L22">22</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L23" href="#L23">23</a><span class="code-text">Multiple characters are currently not supported, but planned for future release.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L24" href="#L24">24</a><span class="code-text"></span></span></pre></div></div>
</main>
</body>
</html>
