Title: Helix as a glorious modern vim
Date: 2022-11-29 20:45

I've been a [vim](https://vim.org) user for more than 20 years now.
I've moved to [neovim](https://neovim.io) a couple of years ago,
attracted by the smaller codebase, the gradual port to [lua](https://en.wikipedia.org/wiki/Lua_(programming_language)) both for plugins and
internals, [tree-sitter](https://tree-sitter.github.io/tree-sitter/)
[integration](https://neovim.io/doc/user/treesitter.html#treesitter),
[LSP](https://en.wikipedia.org/wiki/Language_Server_Protocol)
[support](https://neovim.io/doc/user/lsp.html#lsp), …

But I gradually grown to dislike it: rewriting [my
vimrc](https://dustri.org/pub/vimrc) into lua felt like
a [cumbersome chore](https://github.com/nanotee/nvim-lua-guide)
that only increases its verbosity at the price of its portability,
for no gains at all.
LSP support is done via [yet another plugin](https://github.com/neovim/nvim-lspconfig)
and [a ton of
boilerplate](https://github.com/neovim/nvim-lspconfig#suggested-configuration),
[same for tree-sitter](https://github.com/nvim-treesitter/nvim-treesitter).
Moreover, neovim doesn't have plans to have support for [vimscript9](https://www.vim.org/vim90.php),
meaning that the plugin ecosystem will soon be split into
vimscript/lua/vimscript9.

Speaking of plugins: everything requires one:
Want a theme? [plugin](https://github.com/arcticicestudio/nord-vim).
Want fuzzy-finding? [plugins](https://github.com/junegunn/fzf.vim).
Want a file explorer that doesn't look horrible? [plugin](https://github.com/preservim/nerdtree).
Want to show vcs annotations? [plugin](https://github.com/airblade/vim-gitgutter).
[Modern debugging support](https://github.com/Microsoft/debug-adapter-protocol)? [plugin](https://github.com/mfussenegger/nvim-dap).
LSP support? [plugins](https://github.com/neovim/nvim-lspconfig).
Language independent commenting? [plugin](https://github.com/tpope/vim-commentary).
Snippets? [plugin](https://github.com/garbas/vim-snipmate).
Code outline? [plugin](https://github.com/preservim/tagbar).
[EditorConfig support](https://editorconfig.org)? [plugin](https://github.com/editorconfig/editorconfig-vim).

Coupled with configuration
directives that evolved organically for more than 30 years,
it makes things brittle. For example, `set ttyfast`,
`let c_ansi_typedefs=1`, `autocmd BufnewFile,BufReadPost *.c,*.cpp,*.h,*.hpp
syn match cType "\<[a-zA-Z_][a-zA-Z0-9_]\+_t\>"`, `nnoremap <Leader>oc :e
%<.c<CR>`, `map <Leader>q ::b#<bar>bd#<CR>`, ` set fillchars+=vert:│`, … Good
luck figuring out what they're doing, or even why you added them to your
configuration in the first place. 
Reading (neo)vim's documentation is a trip down memory-lane: `:help
php3.vim` (1997) is still a thing, `:help java.vim` mentions java 1.0.2 (1996),
`:help mapple.vim` mentions [Maple V
RC4](https://en.wikipedia.org/wiki/Maple_(software)#Version_history) (1996),
`:help postscript.vim` says that the default highlighted version is [Postscript
2](https://en.wikipedia.org/wiki/PostScript#PostScript_Level_2) (1991) "since
this is the most prevalent version currently.",
`:help xf86conf.vim` only mentions [XFree86 v3](https://en.wikipedia.org/wiki/XFree86#Release_history) (1994)
and [XFree86 v4](https://en.wikipedia.org/wiki/XFree86#Release_history) (2000),
…

Speaking of legacy, some keymaps are weird as well: `C-]` to follow a symbol
but `C-t` to jump back because `C-[` is equivalent to `<Esc>`, `u` to undo but
`C-r` to redo, the `g` prefix is usually used for `go to` commands like `gd`
for `g`o to `d`eclaration, except that `g~` is to swap case, `gUU` to uppercase
the current line,nd `gv` to reselect the previous selection. `z` is to
manage folds except `z{number}` is to resize panes and `z=` is to
suggest spellings for the words under/after the cursor.
Autocompletion is *interesting* as well, with
`C-x` to enter completion, then `C-l`, `C-n`, `C-k`, `C-t`, `C-i`,
`C-]`, `C-f`, `C-d`, `C-v`, `C-u`,
`C-q`, `s` or `C-p` depending on how you want to autocomplete, and so on.

Moreover, while the idea of [modal
editing](https://en.wikipedia.org/wiki/Vi#Interface) is the best thing since
the invention of the banana curving machine, vim's `Verb → Object` construct is
awkward at best. Text editing isn't
[linguistics](https://en.wikipedia.org/wiki/Verb%E2%80%93object_word_order): I
might say "I want to delete this line of text", but what I'm thinking when
dealing with code is "this part of the code, here, I'd like to delete it". It's
pretty common to apply an action
to the wrong object: maybe you wanted to delete 6 lines instead of 5, but you
eyeballed it wrong? It's possible to *fix this* by making use of
vim's [visual mode](http://vimdoc.sourceforge.net/htmldoc/visual.html#Visual),
transforming it into `Selection → Action`, letting you see what you're doing.

![Helix' logo]({static}/images/helix_logo.png)

Enter [Helix](https://helix-editor.com): written in
[Rust](https://rust-lang.org), inspired by vim and
[kakoune](https://kakoune.org), with a neat
[vision](https://github.com/helix-editor/helix/blob/master/docs/vision.md):
Cross-platform, modal, terminal first, native, lightweight, batteries
included, modern, actively developed, … 

Visually, [my neovim]({static}/images/vim.png) and my [helix]({static}/images/helix.png)
are super-similar, but for the later, there is no
need to fiddle around to get LSP working, it just works. For
[openmw](https://gitlab.com/openmw/openmw), a large C++ project, I
only had to `cd openmw; mkdir build; cd build; cmake
-DCMAKE_EXPORT_COMPILE_COMMANDS=1 ..; make -j $(nproc)` to generate the
[`compile_commands.json`](https://clang.llvm.org/docs/JSONCompilationDatabase.html)
and that was it, LSP was simply working. To use tree-sitter, `hx -g fetch build` and that's it.
EditorConfig is [natively supported](https://github.com/helix-editor/helix/pull/1777).
Multi-selection is a thing, no need to hack with macros and visual mode. Every
cool thing from vim is there as well: buffers, registers, windows, command
mode, … it also comes with [a bunch of modern
themes](https://github.com/helix-editor/helix/tree/master/runtime/themes): no
plugins required.

While vim commands are burned in my brain, helix' ones are making way more sense.
For example, to replace the word `one` with `two` in a whole document:

- vim: `:%s/one/two/g<Cr>`, with `:` to enter *command
  mode*, `%` to apply the next operand to the whole document, `s` for searching, `/` as a marker,
  `one` as the word to be replaced, marker again, `two` to replace, marker, `g`
  to replace globally.
- helix: `%sone<Cr>ctwo<esc>`, with `%` to select the whole document,
  `s` to `s`elect, `one` for the word to select, then `c` to `c`hange with `two`.

In insert mode, helix uses the [Readline Emacs Key Binding](
https://en.wikipedia.org/wiki/GNU_Readline#Emacs_keyboard_shortcuts), aka the
one used in bash, zsh, osx, emacs, … so should one get lost, insert mode has
familiar shortcuts. Moreover, if you don't like the default configuration or keybindings, it's ok: everything
can be changed by editing a [toml](https://toml.io) file. It's possible to
map any keymap to any
[command](https://github.com/helix-editor/helix/blob/master/helix-term/src/commands.rs),
like `C = ["goto_line_start", "extend_to_line_bounds", "change_selection"]` and `d = { d = ["extend_to_line_bounds",
"delete_selection"], t = ["extend_till_char"], s = ["surround_delete"], i =
["select_textobject_inner"], a = ["select_textobject_around"] }`
to make `C` and `d` behave like in vim, without resorting to cryptic black
magic vimscript-like incantations. Check
[helix-vim]( https://github.com/LGUG2Z/helix-vim/ ) for inspiration,
or even [my config](https://dustri.org/pub/config.toml) if you're feeling
adventurous.

There are of course still a bit of rough edges, like the [lack of soft
wrap](https://github.com/helix-editor/helix/issues/136),
[no git integration](https://github.com/helix-editor/helix/issues/227),
no [EditoConfig support](https://github.com/helix-editor/helix/issues/279),
no [`:help`](https://github.com/helix-editor/helix/issues/668),
no [virtual text support](https://github.com/helix-editor/helix/issues/411),
no [snippets support](https://github.com/helix-editor/helix/issues/395),
[more than 150 dependencies](https://github.com/helix-editor/helix/blob/master/Cargo.lock),
my helix folder (sources + binaries) weights 1.5G,
… but it's getting there.

If you want to give it a try, there is of course an equivalent to
[vimtutor](https://linux.die.net/man/1/vimtutor) that can be invoked via the
[`:tutor`](
https://github.com/helix-editor/helix/blob/master/runtime/tutor.txt) command,
and there are [cheat-sheets]( https://cheatography.com/hiddenmonkey/cheat-sheets/helix/)
and [documentation]( https://docs.helix-editor.com/keymap.html). And if you
don't want to read things and simply start using it, [minor
modes](https://docs.helix-editor.com/keymap.html#minor-modes) will make it
easy: pressing `<space>` will [open a menu]({static}/images/menu_space.png) in
which pressing `w` (for `W`indow Management) opens [another
one]({static}/images/menu_space.png) and so on. The same system is used for
registers management, jumping to places, command mode, match mode, …

Moreover, it's __fast__ compared to vim/neovim: editing large yaml file
isn't sluggish, visual selection and completion are instant, 
syntax highlighting doesn't choke on long lines, …

In a couple of years, or maybe months, this could become a serious contender to
(neo)vim, but more importantly, my main editor.
