<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>book/src/registers.md - fork/helix @ 24.07</title>
<meta name="description" content="book/src/registers.md in fork/helix at 24.07.">
<meta property="og:title" content="book/src/registers.md - fork/helix @ 24.07">
<meta property="og:description" content="book/src/registers.md in fork/helix at 24.07.">
<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="24.07" data-tip="079f544260f4f5eaff08104bf07abd57bfb7b611">
<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>24.07</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 class="current" href="/fork/helix/ref/24.07/">24.07</a><a 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/24.07/tree/book/">book</a> / <a href="/fork/helix/ref/24.07/tree/book/src/">src</a> / <span class="cur">registers.md</span></nav>
<span class="view-stats"><span>2.4 KiB</span><span>54 lines</span></span><span class="actions"><a class="raw" href="/fork/helix/raw/2edf7e27a271ae9a7e5a92392b039e307e8890ff/book/src/registers.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>Registers</h2>
<ul>
<li><a href="#user-defined-registers">User-defined registers</a></li>
<li><a href="#default-registers">Default registers</a></li>
<li><a href="#special-registers">Special registers</a></li>
</ul>
<p>In Helix, registers are storage locations for text and other data, such as the
result of a search. Registers can be used to cut, copy, and paste text, similar
to the clipboard in other text editors. Usage is similar to Vim, with <code>"</code> being
used to select a register.</p>
<h3>User-defined registers</h3>
<p>Helix allows you to create your own named registers for storing text, for
example:</p>
<ul>
<li><code>"ay</code> - Yank the current selection to register <code>a</code>.</li>
<li><code>"op</code> - Paste the text in register <code>o</code> after the selection.</li>
</ul>
<p>If a register is selected before invoking a change or delete command, the selection will be stored in the register and the action will be carried out:</p>
<ul>
<li><code>"hc</code> - Store the selection in register <code>h</code> and then change it (delete and enter insert mode).</li>
<li><code>"md</code> - Store the selection in register <code>m</code> and delete it.</li>
</ul>
<h3>Default registers</h3>
<p>Commands that use registers, like yank (<code>y</code>), use a default register if none is specified.
These registers are used as defaults:</p>
<table><thead><tr><th>Register character</th><th>Contains</th></tr></thead><tbody>
<tr><td><code>/</code></td><td>Last search</td></tr>
<tr><td><code>:</code></td><td>Last executed command</td></tr>
<tr><td><code>"</code></td><td>Last yanked text</td></tr>
<tr><td><code>@</code></td><td>Last recorded macro</td></tr>
</tbody></table>
<h3>Special registers</h3>
<p>Some registers have special behavior when read from and written to.</p>
<table><thead><tr><th>Register character</th><th>When read</th><th>When written</th></tr></thead><tbody>
<tr><td><code>_</code></td><td>No values are returned</td><td>All values are discarded</td></tr>
<tr><td><code>#</code></td><td>Selection indices (first selection is <code>1</code>, second is <code>2</code>, etc.)</td><td>This register is not writable</td></tr>
<tr><td><code>.</code></td><td>Contents of the current selections</td><td>This register is not writable</td></tr>
<tr><td><code>%</code></td><td>Name of the current file</td><td>This register is not writable</td></tr>
<tr><td><code>+</code></td><td>Reads from the system clipboard</td><td>Joins and yanks to the system clipboard</td></tr>
<tr><td><code>*</code></td><td>Reads from the primary clipboard</td><td>Joins and yanks to the primary clipboard</td></tr>
</tbody></table>
<p>When yanking multiple selections to the clipboard registers, the selections
are joined with newlines. Pasting from these registers will paste multiple
selections if the clipboard was last yanked to by the Helix session. Otherwise
the clipboard contents are pasted as one selection.</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>Registers</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"><a-p>- </a-p>[User-defined registers](#user-defined-registers)</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L4" href="#L4">4</a><span class="code-text"><a-p>- </a-p>[Default registers](#default-registers)</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L5" href="#L5">5</a><span class="code-text"><a-p>- </a-p>[Special registers](#special-registers)</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L6" href="#L6">6</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L7" href="#L7">7</a><span class="code-text"><a-p>In Helix, registers are storage locations for text and other data, such as the</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L8" href="#L8">8</a><span class="code-text"><a-p>result of a search. Registers can be used to cut, copy, and paste text, similar</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L9" href="#L9">9</a><span class="code-text"><a-p>to the clipboard in other text editors. Usage is similar to Vim, with `&quot;` being</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L10" href="#L10">10</a><span class="code-text"><a-p>used to select a register.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L11" href="#L11">11</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L12" href="#L12">12</a><span class="code-text"><a-p>### </a-p><a-tt>User-defined registers</a-tt></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"><a-p>Helix allows you to create your own named registers for storing text, for</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L15" href="#L15">15</a><span class="code-text"><a-p>example:</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L16" href="#L16">16</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L17" href="#L17">17</a><span class="code-text"><a-p>- `&quot;ay` - Yank the current selection to register `a`.</a-p></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>- `&quot;op` - Paste the text in register `o` after the selection.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L19" href="#L19">19</a><span class="code-text"></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>If a register is selected before invoking a change or delete command, the selection will be stored in the register and the action will be carried out:</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L21" href="#L21">21</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L22" href="#L22">22</a><span class="code-text"><a-p>- `&quot;hc` - Store the selection in register `h` and then change it (delete and enter insert mode).</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L23" href="#L23">23</a><span class="code-text"><a-p>- `&quot;md` - Store the selection in register `m` and delete it.</a-p></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 class="code-break">
</span></span><span class="code-line"><a class="ln" id="L25" href="#L25">25</a><span class="code-text"><a-p>### </a-p><a-tt>Default registers</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L26" href="#L26">26</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L27" href="#L27">27</a><span class="code-text"><a-p>Commands that use registers, like yank (`y`), use a default register if none is specified.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L28" href="#L28">28</a><span class="code-text"><a-p>These registers are used as defaults:</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L29" href="#L29">29</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L30" href="#L30">30</a><span class="code-text"><a-p>| Register character | Contains              |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L31" href="#L31">31</a><span class="code-text"><a-p>| ---                | ---                   |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L32" href="#L32">32</a><span class="code-text"><a-p>| `/`                | Last search           |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L33" href="#L33">33</a><span class="code-text"><a-p>| `:`                | Last executed command |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L34" href="#L34">34</a><span class="code-text"><a-p>| `&quot;`                | Last yanked text      |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L35" href="#L35">35</a><span class="code-text"><a-p>| `@`                | Last recorded macro   |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L36" href="#L36">36</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L37" href="#L37">37</a><span class="code-text"><a-p>### </a-p><a-tt>Special registers</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L38" href="#L38">38</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L39" href="#L39">39</a><span class="code-text">Some registers have special behavior when read from and written to.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L40" href="#L40">40</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L41" href="#L41">41</a><span class="code-text">| Register character | When read              | When written             |</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L42" href="#L42">42</a><span class="code-text">| ---                | ---                    | ---                      |</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L43" href="#L43">43</a><span class="code-text">| `_`                | No values are returned | All values are discarded |</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L44" href="#L44">44</a><span class="code-text">| `#`                | Selection indices (first selection is `1`, second is `2`, etc.) | This register is not writable |</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L45" href="#L45">45</a><span class="code-text">| `.`                | Contents of the current selections | This register is not writable |</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L46" href="#L46">46</a><span class="code-text">| `%`                | Name of the current file | This register is not writable |</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L47" href="#L47">47</a><span class="code-text">| `+`                | Reads from the system clipboard | Joins and yanks to the system clipboard |</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L48" href="#L48">48</a><span class="code-text">| `*`                | Reads from the primary clipboard | Joins and yanks to the primary clipboard |</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L49" href="#L49">49</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L50" href="#L50">50</a><span class="code-text">When yanking multiple selections to the clipboard registers, the selections</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L51" href="#L51">51</a><span class="code-text">are joined with newlines. Pasting from these registers will paste multiple</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L52" href="#L52">52</a><span class="code-text">selections if the clipboard was last yanked to by the Helix session. Otherwise</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L53" href="#L53">53</a><span class="code-text">the clipboard contents are pasted as one selection.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L54" href="#L54">54</a><span class="code-text"></span></span></pre></div></div>
</main>
</body>
</html>
