@gregorlohaus/codemirror-helix
v0.1.0
Published
Helix-editor-style modal editing for CodeMirror 6 (multiple selections, select mode, goto/match modes, textobjects, surround, registers, search).
Maintainers
Readme
@gregorlohaus/codemirror-helix
Helix-style modal editing for CodeMirror 6.
Selection-first editing with multiple selections, Normal/Insert/Select modes, goto & match modes, textobjects, surround, registers, counts, and search.
A core motions subset — broad coverage of everyday Helix keys, not full parity. No tree-sitter textobjects, LSP gotos, macros, or jumplist.
Install
bun add @gregorlohaus/codemirror-helix
# peers: @codemirror/{state,view,commands,language,search}Usage
import { EditorView, basicSetup } from "codemirror";
import { helix } from "@gregorlohaus/codemirror-helix";
new EditorView({
doc: "hello world",
extensions: [basicSetup, helix()],
parent: document.body,
});helix() needs a selection drawer for multi-cursor rendering — basicSetup
(or drawSelection()) covers it.
Options
helix({
startInInsert: false, // start in Normal mode (default)
statusBar: true, // show the bottom mode line
// Let an open autocomplete popup eat the first Escape instead of leaving Insert:
escapeGuard: (state) => completionStatus(state) === "active",
});Keys
Starts in Normal mode. The status line shows the mode, pending count, register, and selection count.
| Group | Keys |
| --- | --- |
| Modes | i/a insert before/after, I/A line start/end, o/O open line, v select (extend), Esc normal |
| Motion | h j k l, w W b B e E, f t F T {char}, Alt-. repeat find, Home/End, counts (3w) |
| Goto g | gg/Ng line, ge end, gh/gl line ends, gs first non-blank, gt/gc/gb view top/center/bottom |
| Select | x line (repeat extends), X line bounds, % all, ; collapse, Alt-; flip, Alt-: forward, , keep primary, Alt-, remove primary, (/) rotate, _ trim |
| Multi | s select regex, S split, K/Alt-K keep/remove, C copy selection below, Alt-C above |
| Match m | mm matching bracket, mi{o}/ma{o} inside/around (w W p ( [ { < " ' \ m), ms{c}surround,md{c}delete,mr{c}{c}replace |
| Edit |ddelete,cchange,yyank,p/Ppaste,Rreplace w/ register,r{c}replace char,~/`` /`Alt- `` case,Jjoin,>/<indent,u/Uundo/redo |
| Registers |"{c}select register for the next yank/delete/paste |
| Search |/ ?search,n/Nnext/prev,*search selection |
| View |zz/zt/zbcenter/top/bottom,Ctrl-d/Ctrl-uhalf page,Ctrl-f/Ctrl-bpage |
| Clipboard |space ycopy,space p/space P` paste (system clipboard) |
s/S/K/Alt-K open a prompt and preview live as you type the regex;
Enter commits, Esc restores the original selection.
License
MIT
