Kakoune is a modal text editor similar to the likes of vim, albeit much younger. It’s probably the software I rely on most day to day, and I think it deserves a shout out.

Delegation

I think most editors and IDE’s approach problems by either creating new solutions or wrapping existing solutions. Let’s use window/tab management as an example. This is a feature that we have come to expect of a text editor. And when we think of most software in this category pretty much all of them have created their own solution to this problem.

A great example of where many editors opt for delegation instead is language completion. I remember not long ago when an IDE was typically tied to a specific language. Why? Simple, it’s a lot of work. Meanwhile editors like vim were delegating to external programs like ctags. More recently language servers have become more popular, allowing editors to support smart language features without shouldering the burden of implementation themselves. They delegate that feature to language servers instead.

I believe there is a middle ground between delegation and owning a feature. Wrapping. Take for example fzf.vim. At time of writing this file contains 1445 lines of vimscript. vim doesn’t support delegating this entire feature to another program, so parts of the feature must be owned by the editor (or in this case a plugin).

Now think of the Unix philosophy.

Write programs that do one thing and do it well. Write programs to work together. Write programs to handle text streams, because that is a universal interface.

Compared to most editors kakoune is a better Unix citizen. Off the top of my head here are a list of common features that kakoune does not implement:

  • window/tab management
  • built-in terminal
  • language completion
  • fuzzy finder
  • file tree
  • debugging

On the flip side here are some features it does implement:

  • modal editing
  • buffer management
  • syntax highlighting (maybe it shouldn’t though)
  • client-server architecture
  • a bare-bones configuration language that delegates to bash/sh
  • an interface for remote control

You might be wondering, why doesn’t kakoune implement basic things like window/tab management? Well, there are plenty of other programs that do, such as kitty, tmux and i3wm. All of these programs serve a more general purpose than “window/tab management for text buffers”. By delegating to other programs kakoune can focus on what it does well, text editing, and you get to use programs that are designed to solve the other problems. It also means you don’t have to juggle multiple implementations of the same feature. For example, I use i3 for window/tab management of all programs, not just kakoune. It doesn’t matter if the window to the right is an instance of kakoune or my email client, moving to it is the same key and works exactly the same way.

To see the difference let’s now look at a fzf integration for kakoune1. Here is the code for it:

map -docstring 'file picker' global normal <c-f> ': connect terminal-popup kcr fzf files<ret>'

And here is the sh script it is calling. 19 lines, and most of that is comments. This isn’t wrapping fzf, it is delegating to it.

It’s similar to how I use broot as a fuzzy finder too. Here is a picture:

screenshot of how my kakoune configuration looks

And here is my configuration:

define-command broot-overlay -params 0.. -file-completion -docstring 'Choose file with broot' %{
    connect popup broot "--conf=%val{config}/broot/select.toml" %arg{@}
}

Editing

I already wrote a post about why modal editing is great, where I touch on why I think kakoune’s modal editing experience is better, as it is centered around a multi-cursor approach. This means you can see how each operation affects each input as you go, as opposed to vim where you have to keep the context (other inputs) in your head as you go. I’d recommend taking a look at kakoune-tv, where you can see many of the vim-golf solutions in kakoune. It goes beyond multiple cursors though. In kakoune you can apply many of the concepts of mathematics to selections, such as unions and intersections. You need only to read some of the very thoughtful discussions on the kakoune forum to see how powerful some of those concepts are. Before you get intimidated, know that you don’t need to use or understand these concepts to use kakoune effectively. They are there if you want to leverage them, you’re still getting a great experience if you don’t.

Summary

So there you have it, the two things that make kakoune so special for me. In most cases it delegates other responsibilities to other tools, and it provides an advanced editing experience of the likes of vim or Emacs in a friendly, accessible package. If you end up trying it out feel free to let me know how it goes, and I’m happy to answer any questions you might have!


  1. Disclaimer: this does depend on kakoune.cr, an excellent CLI tool that offers a simpler interface for remote control of kakoune. ↩︎