.::.
 .:    :.
:  | /   :
:  |/\   :
 ':   ::'
   '::'   

Kakoune - Selection juggling

Part I - Installing Kakoune

Kakoune shouldn't be too hard to install, as it can be installed via standard package managers. It is not available via Flatpak/Snap as far as I am aware of, so if you want latest version of Kakoune on a stable system, you are probably going to need to compile it from source.

Part II - New Text Model

Kakoune uses intriguing hybrid navigation/selection model. Using standard Vim HJKL keys, as well as moving by word seems identical, until Shift key is pressed. The cursor in Kakoune is not really a cursor, it is simply a selection that can be extended and manipulated.

When using normal, unshifted keys, the selection simply moves around, whereas when the user presses Shift along with it, the selection is extended. To access secondary function, or direction of a key, one must use the Alt key, for example:

Along with this new selection model, comes reversed operation order. In Vim for example, to delete 2 words forward one would press d2w. In Kakoune however, that operation would be written as 2Wd, which does the following:

That's also why in Kakoune you don't have separate bindings to delete one character or an object, in Kakoune every deletion operation is done using simply d, after selecting the desired portion of the buffer, or simply deleting character under the cursor. While talking about selecting objects, I quite enjoy the fact that nearly every command that expects additional keystroke has its own little helper menu.

Nearly every command is documented and has a little popup menu that you can check if you want to know what the particular function does when executed, what arguments it needs etc. It can be done as well with user defined commands and key bindings.

Kakoune also supports modern regex matching and replacing, as well as native multiple cursor support, which can definitely come in handy if you are in need of good multi cursor support out of the box. Kakoune can dynamically filter those multiple cursors based on regex criteria, as well as many other things. For more info, I'd recommend taking a look at Kakoune's manual and homepage.

Part III - Customization

Kakoune's configuration language is heavily reliant on standard shell, which can be used to provide basic logic and interaction with standard UNIX utilities, such as sort, nl, column etc. to create more sophisticated functions, such as sorting selected lines or converting comma separated list to a table. That also means, that to create a keybinding to toggle visibility of whitespaces, one needs to create something like this:

Which isn't bad, however, it just leaves a bad aftertaste in my mouth. Being based on UNIX philosophy do one thing and do it well, it also does not have its own window management system. User must use tmux along with Kakoune to have any kind of window splitting available to them, or just use tiling window manager.

Conclusion

Overall Kakoune is quite an interesing take on well known and liked Vim keybindings. It adds native multi cursor support that are enhanced by quite good and fast regex filtering and matching. It is fast and light on system resources, fairly customizable and can interact with your existing scripts and various UNIX tools to get the job done.

References