Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Vix™ for Vim users

You think in motions and you have a .vimrc you have tended for years. This page is for trying Vix without giving that up: a ten-minute exercise you run on a real (tiny) project, then an exact account of which Vim keys behave the same, which behave differently, and what Vix adds on top. Every parity claim here comes from one table that CI runs against Vix on every change and against an unconfigured Vim in a separate job, so the page cannot quietly drift from what the editor does.

Turn on the Vi keymap

Set keymap = "vi" in config.toml, or pick View -> Keymap -> Vi (or open the command palette with Ctrl+P and type keymap). The status bar shows -- NORMAL --. The Spacemacs keymap is the same Vi Normal mode plus a Space leader with a which-key popup.

Three kinds of behavior

The rest of this page keeps these apart:

  • Stock Vim: keys that mean the same in an unconfigured Vim (vim -u NONE, no plugins). Rows of this kind in the table are checked against a real Vim.
  • Optional Vix: things Vix adds that a stock Vim has no keys for: Tree-sitter text objects (cia, daf, ]f), the undo tree view, menus and the command palette. In Vim each of these is a plugin you would install and configure.
  • External tools: behavior that runs another program. Test at point runs cargo test (or your project’s test runner), staging a hunk runs git, and :cn walks the problems parsed from a task’s output, much as Vim’s :make fills the quickfix list through makeprg and errorformat.

A ten-minute migration exercise

The repository ships a tiny Rust crate with one bug in two places, tui/examples/vim-exercise. It needs only cargo and git and no network. Copy it out and make it a git repository, so the last step has something to stage:

cp -R tui/examples/vim-exercise /tmp/vim-exercise
cd /tmp/vim-exercise && git init -q && git add -A && git commit -qm start
vix src/lib.rs                # with keymap = "vi"

The automated test tui/tests/integration/vim_exercise.rs types exactly these keys into Vix, runs the real cargo and git, and checks every step’s result.

  1. Run the test at point. /a_quarter<CR> puts the cursor on the test a_quarter_is_25_percent (stock Vim keys). Then Project -> Test at Point runs just that test (external tool: cargo test -- --exact tests::a_quarter_is_25_percent). It fails: percent(1, 4) is 2, not 25.
  2. Jump to the failure. :cn<CR> goes to the first problem the run reported, the failing assert_eq! on line 24 (the panic location is parsed from the test output, like Vim’s quickfix list).
  3. Edit the argument. gg/10<CR> finds the wrong scale, and ciw100<Esc> changes it (stock Vim). With a Tree-sitter grammar, cia changes the whole argument whatever it looks like (optional Vix).
  4. Repeat. n. finds the same mistake in percent_label and repeats the change (stock Vim).
  5. Take a detour through the undo tree. u undoes the repeat, and 0f1ciw50<Esc> makes a different change instead: the undo history now has two branches. Edit -> Undo Tree… shows them; Up previews the other branch live (both scales 100), Enter keeps it and Esc would put everything back (optional Vix: Vim keeps the same tree and walks it with g-/g+, which Vix’s Vi keymap has too, and :undolist, but draws it only with a plugin).
  6. Rerun the test. :w<CR>, then gg/a_quarter<CR> and Project -> Test at Point again: it passes.
  7. Stage the fix. :6<CR> and Git -> Stage Hunk, then :11<CR> and Git -> Stage Hunk stage the two changed lines (external tool: git); git diff --cached in a shell shows both.

The parity table

Each row is a key sequence typed into a fresh buffer: the buffer before and after (¦ is the cursor, ⏎ a line break; every buffer ends in a line break, not shown), the mode afterwards, and the row’s kind. For a stock-Vim row the last column says whether an unconfigured Vim does the same; where it does not, it gives Vim’s result and why, and the “After in Vix” column is what Vix does today. The rows put deletions and yanks in register a ("a), which Vix and Vim share; the unnamed register is the system clipboard in Vix.

The table lives in tui/tests/integration/vim_parity.rs; this section is generated from it (VIX_UPDATE_VIM_PARITY=1 cargo test -p vix-tui --lib vim_parity), and the CI job that runs stock_rows_match_an_unconfigured_vim fails if Vim stops agreeing with a row.

KeysBeforeAfter in VixModeKindSame in Vim?
3l¦hello worldhel¦lo worldNormalstock Vimyes
$¦hellohell¦oNormalstock Vimyes
0 ab¦c¦ abcNormalstock Vimyes
^ ab¦c ¦abcNormalstock Vimyes
w¦pkg::run(arg);pkg¦::run(arg);Normalstock Vimyes
3w¦pkg::run(arg);pkg::run¦(arg);Normalstock Vimyes
bfoo ba¦rfoo ¦barNormalstock Vimyes
e¦foo barfo¦o barNormalstock Vimyes
W¦a.b c¦a.b cNormalstock Vimno: Vim gives a.b ¦c. WORD motions (W B E) are not implemented: the key does nothing
ggone⏎two⏎th¦ree¦one⏎two⏎threeNormalstock Vimyes
G¦one⏎two⏎threeone⏎two⏎¦threeNormalstock Vimyes
2G¦one⏎two⏎threeone⏎¦two⏎threeNormalstock Vimyes
4ljj¦abcdef⏎x⏎abcdefabcdef⏎x⏎abcd¦efNormalstock Vimyes: the column is kept across a shorter line
2f.¦a.b.ca.b¦.cNormalstock Vimyes
t.¦ab.ca¦b.cNormalstock Vimyes
F.a.b.¦ca.b¦.cNormalstock Vimyes
T.a.b.¦ca.b.¦cNormalstock Vimyes
f.;¦a.b.ca¦.b.cNormalstock Vimno: Vim gives a.b¦.c. ; and , (repeat the last f/t) are not implemented
}¦one⏎two⏎⏎threeone⏎two⏎¦⏎threeNormalstock Vimyes
{one⏎⏎two⏎th¦reeone⏎¦⏎two⏎threeNormalstock Vimyes
)¦One. Two.One. ¦Two.Normalstock Vimyes
%¦(a [b] c)(a [b] c¦)Normalstock Vimyes
*¦foo bar foo¦foo bar fooNormalstock Vimno: Vim gives foo bar ¦foo. * and # are not implemented
/bar<CR>¦foo barfoo ¦barNormalstock Vimyes: / opens Vix’s find bar
/o<CR>n¦xo oxo ¦oNormalstock Vimyes
/bar<CR>"ax¦foo barfoo ¦arNormalstock Vimyes: <CR> closes the find bar and returns to Normal mode
/bar<CR><Esc>"ax¦foo barfoo ¦arNormalstock Vimyes
"adw¦foo bar¦barNormalstock Vimyes
"ade¦foo bar¦ barNormalstock Vimyes
"add¦one⏎ two ¦twoNormalstock Vimyes
"a2dd¦one⏎two⏎three¦threeNormalstock Vimyes
"adwfoo ¦bar⏎bazfoo¦ ⏎bazNormalstock Vimyes: dw on a line’s last word keeps the line break
"ad$fo¦o barf¦oNormalstock Vimyes
"aDfo¦o barf¦oNormalstock Vimyes
"ax¦abc¦bcNormalstock Vimyes
"a3x¦abcd¦dNormalstock Vimyes
"aXab¦ca¦cNormalstock Vimyes
"adf.¦a.b.c¦b.cNormalstock Vimyes
"a2d3w¦a b c d e f g h¦g hNormalstock Vimyes: the two counts multiply
"adj¦one⏎two⏎three¦threeNormalstock Vimyes
"adGone⏎¦two⏎three¦oneNormalstock Vimyes
"acwX<Esc>¦foo bar¦X barNormalstock Vimyes
"accX<Esc> fo¦o⏎bar¦X⏎barNormalstock Vimyes: an unconfigured Vim has noautoindent, so neither keeps the indent
"aCX<Esc>fo¦o barfo¦XNormalstock Vimyes
"asX<Esc>¦abc¦XbcNormalstock Vimyes
rX¦abc¦XbcNormalstock Vimyes
2rX¦abcX¦XcNormalstock Vimyes
4rX¦abc¦abcNormalstock Vimyes: too few characters left: nothing happens
r<CR>a¦bcda⏎¦cdNormalstock Vimyes
2r<CR>a¦bcda⏎¦dNormalstock Vimyes: {count}r<CR> replaces the characters with one line break
r<CR>j.a¦bc⏎defa⏎c⏎⏎¦efNormalstock Vimyes
~¦abc¦abcNormalstock Vimno: Vim gives A¦bc. ~ is not implemented
J¦one⏎twoone¦ twoNormalstock Vimyes
3J¦one⏎ two⏎)threeone two¦)threeNormalstock Vimyes: leading white space goes; no space before )
>>¦one¦oneNormalstock Vimno: Vim gives ¦one. > and < are not implemented
"ayy"ap¦one⏎twoone⏎¦one⏎twoNormalstock Vimyes
"ayw"aP¦foo barfoo¦ foo barNormalstock Vimyes
"ayl"a3p¦abaaa¦abNormalstock Vimyes
"ayiwfoo b¦arfoo ¦barNormalstock Vimyes
"adiwfoo b¦ar bazfoo ¦ bazNormalstock Vimyes
"adawfoo b¦ar bazfoo ¦bazNormalstock Vimyes
"adi(f(a, ¦b)f(¦)Normalstock Vimyes
"adibf(a, ¦b)f(¦)Normalstock Vimyes
"ada"say "h¦i" nowsay ¦nowNormalstock Vimyes
"ada"say "h¦i"sa¦yNormalstock Vimyes: no white space after the quote: the white space before it goes
"aci{X<Esc>{ a¦b }{¦X}Normalstock Vimyes
"adi<lt><a¦b><¦>Normalstock Vimyes
"adipone⏎tw¦o⏎⏎threeone⏎tw¦o⏎⏎threeNormalstock Vimno: Vim gives ¦⏎three. ip/ap and is/as are not implemented: the operator is cancelled
v¦abc¦abcVisualstock Vimyes
Va¦bca¦bcVisual Linestock Vimyes
Vja¦bc⏎deabc⏎d¦eVisual Linestock Vimyes
vll"ad¦hello¦loNormalstock Vimyes
Vj"ad¦one⏎two⏎three¦threeNormalstock Vimyes
viw"ayfoo b¦arfoo ¦barNormalstock Vimyes
"avlld¦hello¦loNormalstock Vimno: Vim gives ¦lo. same text, but a "a typed before v selects the register in Vix; Vim drops it and writes the unnamed register
vw"ad¦foo barfoo ¦arNormalstock Vimno: Vim gives ¦ar. Visual mode moves with h j k l only: w moves the cursor and drops the selection
vl"ad.¦abcdef¦cdefNormalstock Vimno: Vim gives ¦ef. a Visual operator is not dot-repeatable: . does nothing
"adw.¦a b c¦cNormalstock Vimyes
"a2dw3.¦a b c d e f g¦f gNormalstock Vimyes: a count before . replaces the recorded one
"ax.¦abc¦cNormalstock Vimyes
"aciwX<Esc>w.¦foo barX ¦XNormalstock Vimyes
A;<Esc>j.¦one⏎twoone;⏎two¦;Normalstock Vimyes
ofoo<Esc>.¦toptop⏎foo⏎fo¦oNormalstock Vimyes
"arX.¦abc¦XbcNormalstock Vimyes: . repeats r where the cursor is
J.¦a⏎b⏎ca b¦ cNormalstock Vimyes
iX<Esc>ab¦cab¦XcNormalstock Vimyes
aX<Esc>¦abca¦XbcNormalstock Vimyes
AX<Esc>¦abcabc¦XNormalstock Vimyes
IX<Esc> a¦bc ¦XabcNormalstock Vimyes
oX<Esc>¦one⏎twoone⏎¦X⏎twoNormalstock Vimyes
OX<Esc>one⏎¦twoone⏎¦X⏎twoNormalstock Vimyes
i<Esc>¦abc¦abcNormalstock Vimyes: never steps back past the line’s start
iXab¦cabX¦cInsertstock Vimyes
iXY<BS><Esc>¦c¦XcNormalstock Vimyes
"ax"axu¦abc¦bcNormalstock Vimyes
"aciwXY<Esc>u¦foo bar¦foo barNormalstock Vimyes: one u undoes the whole change
"axu<C-r>¦abc¦bcNormalstock Vimyes
"ax"ax2u2<C-r>¦abc¦cNormalstock Vimyes
"ax"axuug+¦abc¦bcNormalstock Vimyes
"axul"axg-a¦bcda¦cdNormalstock Vimyes: g- walks back in time across undo branches, where u would not
:2<CR>¦one⏎twoone⏎¦twoNormalstock Vimyes
:s/o/0/<CR>¦foo¦f0oNormalstock Vimyes
:s/o/0/g<CR>¦foo¦f00Normalstock Vimyes
:%s/a/b/g<CR>¦a⏎ab⏎¦bNormalstock Vimyes
:s/./X/<CR>¦a.b¦a.bNormalstock Vimno: Vim gives ¦X.b. :s takes literal patterns only and refuses Vim pattern syntax such as ., leaving the buffer unchanged
"aciaX<Esc>fn f(a: u8, ¦b: u8) {}fn f(a: u8, ¦X) {}Normaloptional Vixn/a: Tree-sitter argument object (a plugin in Vim)
"adaffn a() {}⏎fn ¦b() {}fn a() {}⏎¦Normaloptional Vixn/a: Tree-sitter function object (a plugin in Vim)
]f¦fn a() {}⏎fn b() {}fn a() {}⏎¦fn b() {}Normaloptional Vixn/a: Tree-sitter next-function motion (a plugin in Vim)
:cn<CR>¦one⏎twoone⏎t¦woNormalexternal tooln/a: after a task printed a.txt:2:2: error: boom (Vim: :make with a makeprg)

Known differences, in short

From the table, the places where Vix’s Vi keymap does not yet do what Vim does:

  • Search. * and # are not implemented.
  • Keys not bound yet: W B E, ; ,, ~, > <, and the ip/ap/is/as objects.
  • Visual mode moves with h j k l and the arrows only, its operators are not dot-repeatable, and a register typed before v applies to the Visual operator (Vim ignores it). There is no Visual Block.
  • Ex. :s takes literal patterns only and refuses Vim pattern syntax.
  • Beyond the table: no uppercase, numbered or special registers, no q/@ register macros (Vix records macros from the Edit menu), no Vimscript, and cc does not keep indentation (an unconfigured Vim, with noautoindent, does not either). crates/vix-modal/spec/index.md keeps the exact line.

Where Vix goes further

  • Built in, not assembled. LSP, a debugger, Tree-sitter highlighting and text objects, fuzzy finding, git hunk staging, a terminal, a test runner and a drawn undo tree are menu items that already work. In Vim each is a plugin (or several) to choose, install and configure.
  • Discoverable from the keyboard. Menus (F10), a command palette (Ctrl+P, > for commands) and F1 for every shortcut; : still works.
  • Persistent undo by default. The undo tree survives closing the file, guarded by a content hash. Vim keeps a tree too, and undofile persists it.
  • Safety. Rust and #![forbid(unsafe_code)]. The one embedded script runtime, Rhai, is sandboxed: a script cannot read files, open sockets or start processes, and a project’s own scripts run only after you trust the workspace.

Where Vim still wins

  • The full Vi language, as the list above shows.
  • Extensibility. No Vimscript and no Lua. Rhai scripts (and git repositories of them installed with vix --plugin) add commands, key bindings and buffer transforms, but there is nothing like Vim’s plugin ecosystem: if your workflow depends on a niche plugin, Vix cannot replace it today.
  • Ubiquity. Vim is on every server you will ssh into; Vix is a single static binary you bring along.
  • Maturity. Vim has decades of edge cases handled. Vix is young.

See also


Vix™ and Vix IDE™ are trademarks.