mirror of
https://github.com/helix-editor/helix
synced 2026-03-12 22:58:26 +01:00
361 lines
17 KiB
HTML
361 lines
17 KiB
HTML
<!DOCTYPE HTML>
|
|
<html lang="en" class="colibri sidebar-visible" dir="ltr">
|
|
<head>
|
|
<!-- Book generated using mdBook -->
|
|
<meta charset="UTF-8">
|
|
<title>Migrating from Vim</title>
|
|
|
|
|
|
<!-- Custom HTML head -->
|
|
|
|
<meta name="description" content="">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<meta name="theme-color" content="#ffffff">
|
|
|
|
<link rel="icon" href="favicon.svg">
|
|
<link rel="shortcut icon" href="favicon.png">
|
|
<link rel="stylesheet" href="css/variables.css">
|
|
<link rel="stylesheet" href="css/general.css">
|
|
<link rel="stylesheet" href="css/chrome.css">
|
|
<link rel="stylesheet" href="css/print.css" media="print">
|
|
|
|
<!-- Fonts -->
|
|
<link rel="stylesheet" href="FontAwesome/css/font-awesome.css">
|
|
<link rel="stylesheet" href="fonts/fonts.css">
|
|
|
|
<!-- Highlight.js Stylesheets -->
|
|
<link rel="stylesheet" href="highlight.css">
|
|
<link rel="stylesheet" href="tomorrow-night.css">
|
|
<link rel="stylesheet" href="ayu-highlight.css">
|
|
|
|
<!-- Custom theme stylesheets -->
|
|
<link rel="stylesheet" href="custom.css">
|
|
|
|
|
|
<!-- Provide site root to javascript -->
|
|
<script>
|
|
var path_to_root = "";
|
|
var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "colibri" : "colibri";
|
|
</script>
|
|
<!-- Start loading toc.js asap -->
|
|
<script src="toc.js"></script>
|
|
</head>
|
|
<body>
|
|
<div id="body-container">
|
|
<!-- Work around some values being stored in localStorage wrapped in quotes -->
|
|
<script>
|
|
try {
|
|
var theme = localStorage.getItem('mdbook-theme');
|
|
var sidebar = localStorage.getItem('mdbook-sidebar');
|
|
|
|
if (theme.startsWith('"') && theme.endsWith('"')) {
|
|
localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1));
|
|
}
|
|
|
|
if (sidebar.startsWith('"') && sidebar.endsWith('"')) {
|
|
localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1));
|
|
}
|
|
} catch (e) { }
|
|
</script>
|
|
|
|
<!-- Set the theme before any content is loaded, prevents flash -->
|
|
<script>
|
|
var theme;
|
|
try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
|
|
if (theme === null || theme === undefined) { theme = default_theme; }
|
|
const html = document.documentElement;
|
|
html.classList.remove('colibri')
|
|
html.classList.add(theme);
|
|
html.classList.add("js");
|
|
</script>
|
|
|
|
<input type="checkbox" id="sidebar-toggle-anchor" class="hidden">
|
|
|
|
<!-- Hide / unhide sidebar before it is displayed -->
|
|
<script>
|
|
var sidebar = null;
|
|
var sidebar_toggle = document.getElementById("sidebar-toggle-anchor");
|
|
if (document.body.clientWidth >= 1080) {
|
|
try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
|
|
sidebar = sidebar || 'visible';
|
|
} else {
|
|
sidebar = 'hidden';
|
|
}
|
|
sidebar_toggle.checked = sidebar === 'visible';
|
|
html.classList.remove('sidebar-visible');
|
|
html.classList.add("sidebar-" + sidebar);
|
|
</script>
|
|
|
|
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
|
|
<!-- populated by js -->
|
|
<mdbook-sidebar-scrollbox class="sidebar-scrollbox"></mdbook-sidebar-scrollbox>
|
|
<noscript>
|
|
<iframe class="sidebar-iframe-outer" src="toc.html"></iframe>
|
|
</noscript>
|
|
<div id="sidebar-resize-handle" class="sidebar-resize-handle">
|
|
<div class="sidebar-resize-indicator"></div>
|
|
</div>
|
|
</nav>
|
|
|
|
<div id="page-wrapper" class="page-wrapper">
|
|
|
|
<div class="page">
|
|
<div id="menu-bar-hover-placeholder"></div>
|
|
<div id="menu-bar" class="menu-bar sticky">
|
|
<div class="left-buttons">
|
|
<label id="sidebar-toggle" class="icon-button" for="sidebar-toggle-anchor" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
|
|
<i class="fa fa-bars"></i>
|
|
</label>
|
|
<button id="theme-toggle" class="icon-button" type="button" title="Change theme" aria-label="Change theme" aria-haspopup="true" aria-expanded="false" aria-controls="theme-list">
|
|
<i class="fa fa-paint-brush"></i>
|
|
</button>
|
|
<ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
|
|
<li role="none"><button role="menuitem" class="theme" id="light">Light</button></li>
|
|
<li role="none"><button role="menuitem" class="theme" id="rust">Rust</button></li>
|
|
<li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li>
|
|
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
|
|
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
|
|
<li role="none"><button role="menuitem" class="theme" id="colibri">Colibri</button></li>
|
|
</ul>
|
|
<button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
|
|
<i class="fa fa-search"></i>
|
|
</button>
|
|
</div>
|
|
|
|
<h1 class="menu-title"></h1>
|
|
|
|
<div class="right-buttons">
|
|
<a href="print.html" title="Print this book" aria-label="Print this book">
|
|
<i id="print-button" class="fa fa-print"></i>
|
|
</a>
|
|
<a href="https://github.com/helix-editor/helix" title="Git repository" aria-label="Git repository">
|
|
<i id="git-repository-button" class="fa fa-github"></i>
|
|
</a>
|
|
<a href="https://github.com/helix-editor/helix/edit/master/book/src/from-vim.md" title="Suggest an edit" aria-label="Suggest an edit">
|
|
<i id="git-edit-button" class="fa fa-edit"></i>
|
|
</a>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="search-wrapper" class="hidden">
|
|
<form id="searchbar-outer" class="searchbar-outer">
|
|
<input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
|
|
</form>
|
|
<div id="searchresults-outer" class="searchresults-outer hidden">
|
|
<div id="searchresults-header" class="searchresults-header"></div>
|
|
<ul id="searchresults">
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
|
|
<script>
|
|
document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
|
|
document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
|
|
Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
|
|
link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
|
|
});
|
|
</script>
|
|
|
|
<div id="content" class="content">
|
|
<main>
|
|
<h1 id="migrating-from-vim"><a class="header" href="#migrating-from-vim">Migrating from Vim</a></h1>
|
|
<ul>
|
|
<li><a href="#Delete/Change%20Commands">Delete/Change Commands</a></li>
|
|
<li><a href="#Navigation">Navigation</a></li>
|
|
<li><a href="#Line%20Deletes">Line Deletes</a></li>
|
|
<li><a href="#Comment%20lines,%20Completion,%20Search">Comment lines, Completion, Search</a></li>
|
|
<li><a href="#File%20actions">File actions</a></li>
|
|
</ul>
|
|
<p>Helix's editing model is strongly inspired from Vim and Kakoune, and a notable
|
|
difference from Vim (and the most striking similarity to Kakoune) is that Helix
|
|
follows the <code>selection → action</code> model. This means that whatever you are
|
|
going to act on (a word, a paragraph, a line, etc.) is selected first and the
|
|
action itself (delete, change, yank, etc.) comes second. A cursor is simply a
|
|
single width selection.</p>
|
|
<p><em>Note:</em> As Helix is inspired by Vim and <a href="https://github.com/mawww/kakoune">Kakoune</a>, the keybindings are similar but also have some differences. The content of this page is inspired by <a href="https://github.com/mawww/kakoune/wiki/Migrating-from-Vim">Kakoune Wiki</a>.</p>
|
|
<p>NOTE: Unlike vim, <code>f</code>, <code>F</code>, <code>t</code> and <code>T</code> are not confined to the current line.</p>
|
|
<h2 id="deletechange-commands"><a class="header" href="#deletechange-commands">Delete/Change Commands</a></h2>
|
|
<p>delete a word:</p>
|
|
<ul>
|
|
<li>vim: <code>dw</code></li>
|
|
<li>helix: <code>wd</code></li>
|
|
</ul>
|
|
<p>change a word:</p>
|
|
<ul>
|
|
<li>vim: <code>cw</code></li>
|
|
<li>helix: <code>ec</code> or <code>wc</code> (includes the whitespace after the word)</li>
|
|
</ul>
|
|
<p>delete a character:</p>
|
|
<ul>
|
|
<li>vim: <code>x</code></li>
|
|
<li>helix: <code>d</code> or <code>;d</code> (<code>;</code> reduces the selection to a single char)</li>
|
|
</ul>
|
|
<p>copy a line:</p>
|
|
<ul>
|
|
<li>vim: <code>yy</code></li>
|
|
<li>helix: <code>Xy</code> (<code>X</code> extends all selections to whole lines)</li>
|
|
</ul>
|
|
<p>global replace:</p>
|
|
<ul>
|
|
<li>vim: <code>:%s/word/replacement/g<ret></code></li>
|
|
<li>helix: <code>%sword<ret>creplacement<esc></code></li>
|
|
</ul>
|
|
<p>Explanation: <code>%</code> selects the entire buffer, <code>s</code> opens a prompt for a regex, <code><ret></code> validates the regex and reduces the selection to each match (hence, all occurrences of word are selected). <code>c</code> deletes the selection contents and enter insert mode, replacement is typed and then <code><esc></code> goes back to normal mode.</p>
|
|
<h2 id="navigation"><a class="header" href="#navigation">Navigation</a></h2>
|
|
<p>go to first line:</p>
|
|
<ul>
|
|
<li>vim: <code>gg</code></li>
|
|
<li>helix: <code>gg</code></li>
|
|
</ul>
|
|
<p>go to last line:</p>
|
|
<ul>
|
|
<li>vim: <code>G</code></li>
|
|
<li>helix: <code>ge</code></li>
|
|
</ul>
|
|
<p>go to line start:</p>
|
|
<ul>
|
|
<li>vim: <code>0</code></li>
|
|
<li>helix: <code>gh</code></li>
|
|
</ul>
|
|
<p>go to line first non-blank character:</p>
|
|
<ul>
|
|
<li>vim: <code>^</code></li>
|
|
<li>helix: <code>gs</code></li>
|
|
</ul>
|
|
<p>go to line end:</p>
|
|
<ul>
|
|
<li>vim: <code>$</code></li>
|
|
<li>helix: <code>gl</code></li>
|
|
</ul>
|
|
<p>jump to matching bracket:</p>
|
|
<ul>
|
|
<li>vim: <code>%</code></li>
|
|
<li>helix: <code>mm</code></li>
|
|
</ul>
|
|
<h2 id="line-deletes"><a class="header" href="#line-deletes">Line Deletes</a></h2>
|
|
<p>delete to line end:</p>
|
|
<ul>
|
|
<li>vim: <code>D</code></li>
|
|
<li>helix: <code>vgld</code> or <code>t<ret>d</code></li>
|
|
</ul>
|
|
<p>Note: <code>v</code> is used along with <code>gl</code> (go to line end), because <a href="https://github.com/helix-editor/helix/issues/1630"><code>gl</code> does not select text</a>.
|
|
<code>t<ret></code> selects "'til" the newline represented by <code><ret></code>.</p>
|
|
<p>delete entire line:</p>
|
|
<ul>
|
|
<li>vim: <code>dd</code></li>
|
|
<li>helix: <code>xd</code></li>
|
|
</ul>
|
|
<p>Note: <code>x</code> selects the entire line under the cursor</p>
|
|
<h2 id="comment-lines-completion-search"><a class="header" href="#comment-lines-completion-search">Comment lines, Completion, Search</a></h2>
|
|
<p>auto complete:</p>
|
|
<ul>
|
|
<li>vim: <code>C-p</code></li>
|
|
<li>helix: <code>C-x</code></li>
|
|
</ul>
|
|
<p>comment lines:</p>
|
|
<ul>
|
|
<li>vim: <code>gc</code></li>
|
|
<li>helix: <code>Space-c</code></li>
|
|
</ul>
|
|
<p>search for the word under the cursor:</p>
|
|
<ul>
|
|
<li>vim: <code>*</code></li>
|
|
<li>helix: <code>A-o*n</code> (if there's a tree-sitter grammar or LSP) or <code>be*n</code></li>
|
|
</ul>
|
|
<p>Explanation: if there's a grammar or LSP, <code>A-o</code> expands selection to the parent syntax node (which would be the word in our case). Then <code>*</code> uses the current selection as the search pattern, and <code>n</code> goes to the next occurrence. <code>b</code> selects to the beginning of the word, and <code>e</code> selects to the end of the word, effectively selecting the whole word.</p>
|
|
<p>block selection:</p>
|
|
<ul>
|
|
<li>vim: <code>C-v</code>, then expand your selection vertically and horizontally</li>
|
|
<li>helix: There's no "block selection" mode, so instead you'd use multiple cursors. Expand your block selection vertically by adding new cursors on the line below with <code>C</code>, and horizontally using standard movements</li>
|
|
</ul>
|
|
<p>search "foo" and replace with "bar" in the current selection:</p>
|
|
<ul>
|
|
<li>vim: <code>:s/foo/bar/g<ret></code></li>
|
|
<li>helix: <code>sfoo<ret>cbar<esc>,</code></li>
|
|
</ul>
|
|
<p>Explanation: <code>s</code> will open a prompt in the command line for a regex, and select all matches inside the selection (effectively adding a new cursor on each match). Pressing enter will then finalise this step, and allow the <code>c</code> to change the selections to "bar". When done, go back to normal mode with <code><esc></code>, and keep only the primary selection with <code>,</code> (remove all the additional cursors).</p>
|
|
<h2 id="file-actions"><a class="header" href="#file-actions">File actions</a></h2>
|
|
<p>select the whole file:</p>
|
|
<ul>
|
|
<li>vim: <code>ggVG</code></li>
|
|
<li>helix: <code>%</code></li>
|
|
</ul>
|
|
<p>reload a file from disk:</p>
|
|
<ul>
|
|
<li>vim: <code>:e<ret></code></li>
|
|
<li>helix: <code>:reload<ret></code> (or <code>:reload-all<ret></code> to reload all the buffers)</li>
|
|
</ul>
|
|
<p>run shell command:</p>
|
|
<ul>
|
|
<li>vim: <code>:!command</code></li>
|
|
<li>helix: <code>:sh command</code> (or <code>!command</code> to insert its output into the buffer)</li>
|
|
</ul>
|
|
<p>setting a bookmark (bookmarking a location):</p>
|
|
<ul>
|
|
<li>vim: <code>ma</code> to set bookmark with name a. Use <code>`a</code> to go back to this bookmarked location.</li>
|
|
<li>helix: there are no named bookmarks, but you can save a location in the jumplist with <code>C-s</code>, then jump back to that location by opening the jumplist picker with <code><space>-j</code>, or back in the jumplist with <code>C-o</code> and forward with <code>C-i</code></li>
|
|
</ul>
|
|
<p>Helix allows <a href="https://docs.helix-editor.com/keymap.html#insert-mode">some limited movement in <code>insert</code> mode</a> without switching to <code>normal</code> mode.</p>
|
|
<p>Unlike Vim, under Helix, the cursor shape is the same (block) in insert mode and normal mode by default.
|
|
This can be adjusted in configuration:</p>
|
|
<pre><code class="language-toml">[editor.cursor-shape]
|
|
insert = "bar"
|
|
</code></pre>
|
|
<blockquote>
|
|
<p>TODO: Mention textobjects, surround, registers</p>
|
|
</blockquote>
|
|
|
|
</main>
|
|
|
|
<nav class="nav-wrapper" aria-label="Page navigation">
|
|
<!-- Mobile navigation buttons -->
|
|
<a rel="prev" href="ecosystem.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
|
|
<i class="fa fa-angle-left"></i>
|
|
</a>
|
|
|
|
<a rel="next prefetch" href="other-software.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
|
|
<i class="fa fa-angle-right"></i>
|
|
</a>
|
|
|
|
<div style="clear: both"></div>
|
|
</nav>
|
|
</div>
|
|
</div>
|
|
|
|
<nav class="nav-wide-wrapper" aria-label="Page navigation">
|
|
<a rel="prev" href="ecosystem.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
|
|
<i class="fa fa-angle-left"></i>
|
|
</a>
|
|
|
|
<a rel="next prefetch" href="other-software.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
|
|
<i class="fa fa-angle-right"></i>
|
|
</a>
|
|
</nav>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
window.playground_copyable = true;
|
|
</script>
|
|
|
|
|
|
<script src="elasticlunr.min.js"></script>
|
|
<script src="mark.min.js"></script>
|
|
<script src="searcher.js"></script>
|
|
|
|
<script src="clipboard.min.js"></script>
|
|
<script src="highlight.js"></script>
|
|
<script src="book.js"></script>
|
|
|
|
<!-- Custom JS scripts -->
|
|
|
|
|
|
</div>
|
|
</body>
|
|
</html>
|