DEV Community

Cover image for Helix Editor – 90% of Neovim With Kakoune
Sophia Brandt
Sophia Brandt

Posted on • Originally published at rockyourcode.com on

Helix Editor – 90% of Neovim With Kakoune

I’ve spend too many hours setting up the recent NeoVim features (since v0.5): tree-sitter, nvim-lsp, nvim-cmp.

Why?

NeoVim’s parser tool tree-sitter offers a better integration of language servers, syntax highlighting and auto-completion.

The Problem

Vim and NeoVim are great.

However, I put a lot of effort into customizing these editors to my liking, so that I could comfortably use them for coding.

In fact, my configuration has become more complicated over the years.

Migrating my Vim configuration to take advantage of tree-sitter was an exercise in frustration.

Better Than (Neo)Vim?

By chance I stumbled upon a review of Rust text editors on lobste.rs.

The article favorably mentions Helix, a modal text editor inspired by Vim and Kakoune.

Other commentators also seemed taken with this new text editor.

helix text editor

I gave Helix a try and I am pleasantly surprised.

Helix is a fully-fledged text editor that comes with wonderful capabilities out of the box.

For example, you get a fuzzy file finder, language server integration, a vim-surround-like plugin and great editor themes for free.

In the end, Helix offers almost everything I need from a terminal-based text editor with zero config.

After wasting hours of my free time on tweaking NeoVim, Helix’s sane defaults and inbuilt features blew me out of the water.

Kakoune – Why!?

Helix has one advantage over Vim/NeoVim - multiple cursors. This features makes text editing a smoother experience.

Multiple cursors come from Kakoune, a text editor I never heard of.

Vim’s core editing model revolves around verbs and (text) objects. For example, to delete a word, you type dw, like in a natural language like English.

Kakoune turns this model on its head: in Kakoune, you always select text objects first, then operate on them with words.

Helix uses the same model as Kakoune.

The idea is that you always start by making a selection first (that way it’s interactive and you see that you selected the right thing), then you operate on it.

I’m not sure if I can forego my muscle memory and retrain myself to use the “Kakoune” way. For me, it feels incredibly awkward.

I am also missing some commands in normal mode.

For example, I can easily move or copy lines to other locations in the file without having to make a selection and without leaving normal mode.

This is a clash with Kakoune’s/Helix’s philosophy.

What I am missing most is ci (for change inside).

I often use this command to change text in brackets (ci{), single quotes (ci') or other text objects.

Now What?

Helix is in active development.

But even so, the editor is already usable. Because it is written in Rust, it’s fast and stable.

The maintainers plan a plugin system with WebAssembly, which would be a big milestone for the project.

All in all, Helix looks like a valid alternative to Vim/NeoVim if you like modal editors.

My Configuration

Here is my complete configuration file:

theme = "nord"

[editor.cursor-shape]
insert = "bar"
normal = "block"
select = "underline"

[editor.statusline]
left = ["mode", "diagnostics"]
center = ["file-name"]
right = ["selections", "file-type", "file-encoding", "position-percentage", "position"]

[keys.normal]
g = { a = "code_action", o = "goto_last_accessed_file" }
"ret" = ["move_line_down", "goto_first_nonwhitespace"] # Maps the enter key to move to start of next line
X = "extend_line_above"
D = "delete_char_backward"

[keys.insert]
C-space = "completion"
# Move cursor in insert mode
A-h = "move_char_left"
A-j = "move_line_down"
A-k = "move_line_up"
A-l = "move_char_right"
A-o = "open_below"
A-O = "open_above"

Enter fullscreen mode Exit fullscreen mode

It adds a default theme, a few convenience key mappings plus some customisation around the status-line and the cursor.

In comparison, here is my code for the status-line in Vim/NeoVim alone – which is (more or less) a three-liner in Helix.

Links

Top comments (1)

Collapse
 
carlosvigil profile image
Carlos Vigil

mi[ match inside brackets