Wednesday, Mar. 29, 2017

A Better Text Editor Than Vim Now Exists—But Why Does Nobody Use It?

Written By:

|

March 20, 2017

|

Posted In:

A Better Text Editor Than Vim Now Exists—But Why Does Nobody Use It?


Vim is ‘the ubiquitous text editor’—it is one of the few text editors that comes prepackaged in most Linux distributions and works across Linux, Windows, Mac, in GUI and in the terminal. And this is even more surprising when you consider the learning curve. Vim’s system of keyboard hotkeys has been compared to a language and learning any language is a hefty endeavour. But it is this keyboard system that makes Vim so popular. It is widely regarded as the most efficient way to edit text, and you can witness this ninja-like efficiency if you ever watch a game of ‘Vim Golf’ (this is a game where people compete to edit a text file to match a specified end file using Vim but by using the least possible keystrokes). You can play Vim Golf with any text editor actually, and it’s actually an information-theoretically sound way to compare text editors objectively and provide a flame war-ending answer to the question: which text editor is the best?

Vim has always been the clear winner of Vim Golf. Hence the name. Emacs loses out (but you have to remember that Emacs is not just a text editor and so Emacs users still have a basis for their choice) and it only goes downhill from there when you get to Nano, Sublime, Atom and all the other generic editors that have minimal keyboard shortcuts and depend largely on the mouse.

But, a new winner has emerged that actually defeats Vim at its own game. Kakoune is a text editor that beats Vim at Vim Golf challenges with its keyboard system inspired by Vim but which improves on it in some fundamental ways.

How Is Kakoune Better Than Vim?

Vim is a modal text editor (the modal text editor actually). It has three main modes: normal, insert and visual. Kakoune is also a modal text editor, but it has only two modes: insert and normal. Visual and normal mode have been combined into one in this editor, which is actually a keystroke-saving simplification that only increases the power of the editor because of how it handles visual selections. Selections are the basis of Kakoune and it isn’t just limited to single selections like Vim, it is based on multiple selections and multiple cursor positions.

In Vim, if you run a regexp search that yields multiple matches in the file, the first is selected and you can use ‘n’, ‘N’ to cycle through the rest. In Kakoune, when a regexp yields multiple results, all are selected (multiple selections) and without even changing modes (because normal mode and visual mode are the same), you can perform commands on all selections at once (instead of performing it on one and using macros or search + repeat to do it to the rest). Let’s do a Vim Golf comparison of these two editors in this editing situation:

Start file

What Bob does is Bob’s business. What Bob don’t know don’t hurt him. You cain’t hurt Bob. Bob been round here for donkeys years ain’t never seen Bob hurt. I won’t tellya what’s happened to Bob in those years but when you ask him all he says is you cain’t hurt Bob.

End file

Bob Bob Bob Bob Bob Bob Bob Bob

To transform the start file into the end file, let’s first use Vim. This is what I’m confident is the fastest way to do this in Vim (although there may be a regexp possible that does all this in hit but let’s just disregard that for the sake of demonstration). We will use a search and a macro to copy ‘Bob’ to the end of the line, run it until all ‘Bob’s have been copied and then delete the original part of the line:

/Bob<CR>qqnyawma$p`aq7@qd5f.

That’s 25 keys.

Now let’s try using Kakoune. We will multi-select all ‘Bob’s and copy them, delete the entire file then paste the ‘Bob’s:

/Bob<CR>y%d<C-r>2

That’s just 10 keys (!)

It’s an extreme difference in this round of Vim Golf. Kakoune is the clear winner.

What Other Features Does Kakoune Have?

The Kakoune editor has several features that make Vim user’s squirm with envy. Here is just a brief summary:

  • Discoverable keys and commands · Kakoune has menus that pop up when you are typing keys and commands that suggest the available completions. This has been one of the most commonly cited core limitations of Vim (discoverability) since day one. It also has Clippy—the insufferable Microsoft character that provides contextual help but this time it is actually useful and more or less sufferable
  • Multiple clients in the same editing session · Kakoune supports multiple users editing the same file seamlessly
  • Advanced text manipulations · the basic text manipulation commands in Kakoune are highly powerful and can form the basis of virtually any other command in just a few keystrokes. They include selection rotation, indenting and aligning.
  • Multiple selections · as aforementioned

So Why Isn’t Everyone Switching To Kakoune?

Kakoune is not just better than Vim, in its keyboard system, but it’s just extremely cool to work with. There’s no text editing satisfaction greater than editing multiple things at once in real time. The first time I heard about it, it made me want to ditch my painstakingly configured 4000+ line, 100+ plugin writers max vim configuration and start afresh with this new text editor. It tempted me while I was writing this article actually, but I’m not going to. Why? The reason is that I can’t ditch my 100+ plugins—all of which I use semi-regularly, for an editor which albeit is quite complete straight out of the box, still lacks some key plugin functionality. Here are some quite important things that Kakoune doesn’t have because it has such a meagre plugin base:

  • Title case motion
  • Comment motion
  • URL text object (and the plethora of other textobject and motion plugins that Vim benefits from and that increase it’s power combinatorially)
  • Unconditional paste (paste line as characters, etc)
  • Sneak (with Sneak-Streak enabled it becomes the ultimate motion)
  • Auto save (easy to configure on Kakoune with hooks?)
  • Ragtag (the fastest completion for typing html tags)

But I Really Want It

Me too actually but instead of biting the bullet and making the painful switch and maybe even porting some of those Vim plugins to Kakoune, I’m patiently waiting for someone to make a Kakoune plugin for Vim. A really good multiple cursors plugin already exists for Vim. This can already save keystrokes if you don’t mind putting up with some bugginess and with your undo tree getting completely wonkipated. If a real Kakoune plugin were created, I would expect it to be made for NeoVim, and for it to have the same relationship with Vim as that of Spacemacs to Emacs—that of an entirely new editor built on top of the original—with its own plugins and community and etc. If any aspirational programmers are reading this and have become as fascinated with Kakoune as I have (who is not a programmer), then you think this over—I think that if you started developing such a plugin, many people would assist you and it would very quickly become a very big thing.

Share This Article

Related News

10 Obvious Literal Things That Weird You Out When You Think About Them
What Do Nuns And Monks Actually Do?
5 Books That Can Never Be Turned Into Films

About Author

Leave A Reply

Leave a Reply

Your email address will not be published. Required fields are marked *