Vim’s editing grammar is legendary among programmers. It operates on a verb-noun system that allows you to “speak” to your text editor. To delete a word, you type dw (Delete Word). The action verb (d) comes first, followed by the object noun (w).
This “Action → Object” philosophy is undeniably fast. However, it suffers from one major, glaring flaw: you do not know exactly what you are going to delete until after you have already deleted it. If you press di( hoping to delete everything inside a complex, multi-line set of nested parentheses, you are relying entirely on blind faith that you calculated the scope correctly in your head. If you were wrong, you must press u to undo and try again.
Enter Kakoune, the terminal-based text editor created by Maxime Coste that dares to take Vim’s sacred grammar and flip it completely upside down.
In Kakoune, the philosophy is Selection → Action. You select your text first, visually confirm that the selection is exactly what you intend it to be, and then you act upon it. This subtle shift fundamentally changes how you interact with code, especially when combined with Kakoune’s true superpower: first-class, natively integrated multiple selections.
1. The Core Paradigm: Selection-Driven Editing
To understand Kakoune, you must unlearn the Vim habit of blind execution. In Kakoune, every single movement is a selection. Even when you are just moving a single cursor around the screen using your arrow keys, you are technically moving a “one-character selection.”
Let’s look at the difference between Vim and Kakoune for a simple editing task:
Task: Delete the current word.
- In Vim: You press
d(Delete) and thenw(Word). The word instantly vanishes. - In Kakoune: You press
w(Select Word). The word is immediately highlighted on your screen. You look at it. You visually confirm it is the correct word. Then, you pressd(Delete).
Task: Change the text inside a set of quotes.
- In Vim: You press
c(Change),i(Inside),"(Quotes). The text disappears and you enter insert mode. - In Kakoune: You press
M(Select Around),i(Inside),"(Quotes). The text inside the quotes is highlighted. You confirm it is correct. Then you pressc(Change) to enter insert mode.
By shifting to the “Selection First” model, Kakoune completely removes the anxiety of guessing how far an operation will reach. It provides a visual safety net for every single edit you make.
2. Navigating Like a Pro: Extending Selections
Because every movement is a selection, navigation in Kakoune feels simultaneously familiar to Vim users and entirely new.
Kakoune retains the beloved hjkl navigation keys for keeping your hands glued to the home row:
h: Move left.j: Move down.k: Move up.l: Move right.
However, since moving the cursor is just moving a 1-character selection, how do you highlight a block of text? You simply hold down the Shift key to extend the selection.
L(Shift + L): Extends the selection one character to the right.J(Shift + J): Extends the selection one line down.W(Shift + W): Extends the selection to the end of the next word.
Advanced Text Objects
Kakoune provides powerful shortcuts for selecting common programming objects:
x: Selects the entire current line. Pressing it multiple times selects multiple lines.<Alt-i>(Inner Object): Followed by a character likep(paragraph) orw(word), this selects the inner contents of that object.<Alt-a>(Around Object): Similar to Inner, but includes the surrounding whitespace or boundary characters.%: Selects the entire buffer (the entire document). This is crucial for global operations.
3. The Multi-Cursor Revolution
While the selection-first model is brilliant, Kakoune’s true claim to fame is how it handles multiple cursors.
In Vim, multiple cursors are often hacked in via third-party plugins (like vim-multiple-cursors), and they frequently conflict with existing macros or commands. In Kakoune, multiple selections are the foundational mechanic of the entire editor. Every command you issue is applied to every active selection simultaneously.
The Regex Selection Workflow
Imagine you are refactoring a massive Python script. You need to change the variable temp_data_array to processed_items, but only within a specific 50-line function block.
Here is the Kakoune workflow:
- Move your cursor to the top of the function.
- Press
Jrepeatedly to extend your selection down to the bottom of the function block. - Press
s(Select by Regex). A prompt appears at the bottom of the screen. - Type
temp_data_arrayand press Enter. - Kakoune will scan only within your highlighted block and place a distinct, blinking cursor on every single instance of that variable.
- Press
c(Change). All instances disappear. - Type
processed_items. You will watch the text update simultaneously across the entire function. - Press
<Escape>to return to a single cursor.
This workflow is infinitely more intuitive and less error-prone than trying to craft a complex :%s/find/replace/g substitution command.
Splitting Selections
Kakoune offers incredibly granular control over how you spawn cursors:
S(Split by Regex): Instead of selecting matching text, this splits your current selection wherever the regex matches. For example, selecting a comma-separated list and splitting by,will place a cursor on every item in the list.<Alt-s>(Split by Lines): If you have a large block of text selected, pressing<Alt-s>will instantly place a separate cursor at the beginning of every single line within that block. This is perfect for appending formatting characters to the start of multiple lines simultaneously.
4. The Client-Server Architecture
One of the most radical design choices made by Maxime Coste was how Kakoune handles window management.
Vim includes a complex internal window manager allowing you to split your screen (:vsplit, :split) and manage tabs. Kakoune explicitly rejects this approach in favor of the Unix Philosophy (“Do one thing and do it well”).
Kakoune argues that window management is the job of your Terminal Multiplexer (like tmux or zellij) or your graphical Window Manager (like i3 or sway).
How It Works
When you launch Kakoune, you are actually launching a background server and connecting a client to it.
If you want to view a file side-by-side:
- You open a new pane in
tmux. - You run the command
kak -c [session_name]. - The new terminal pane connects to the exact same editing session as your first pane.
Because both terminal windows are connected to the same background server, they share the same buffers, the same clipboard registers, and the same undo history. If you highlight a word in Window A, you will see it highlight in real-time in Window B.
This client-server architecture makes collaborative editing trivial and prevents the editor’s codebase from becoming bloated with complex window-drawing logic.
5. Scripting and Extensibility: Embracing POSIX
Extensibility has always been a pain point for modal editors. Vim relies on Vimscript (which is notoriously archaic) or Lua (which requires learning a dedicated programming language).
Kakoune takes a completely different approach. It integrates directly with the standard POSIX shell.
If you want to write a plugin or a complex macro in Kakoune, you literally write standard shell scripts (Bash, Sh, etc.) that pipe text in and out of the editor.
The %sh{} Expansion
Kakoune allows you to execute shell commands inline and insert the output directly into your buffer.
For example, if you want to insert the current date into your document, you don’t need to write a complex Kakoune script. You just type:
!date<Enter>
This pipes your current selection into the standard Unix date command and replaces it with the output.
For complex scripting, plugins are simply shell scripts that define Kakoune commands. This means that if you already know how to write a bash script, you already know how to write a Kakoune plugin. You can leverage powerful tools like awk, sed, grep, and curl directly within your editor’s configuration files.
6. Installation and Setup
Because Kakoune relies on a modern C++ compiler and standard Unix tools, it is highly portable and easily installed via package managers.
Installation
Debian / Ubuntu / Pop!_OS:
sudo apt update
sudo apt install kakoune
Fedora / RHEL:
sudo dnf install kakoune
Arch Linux:
sudo pacman -S kakoune
macOS (via Homebrew):
brew install kakoune
Once installed, you can launch the editor simply by typing kak in your terminal:
kak index.js
Configuration (kakrc)
Your personalized configuration is stored in a file called kakrc, located at ~/.config/kak/kakrc.
Here is an example of a basic Kakoune configuration that sets up line numbers, customizes the tab width, and applies a color scheme:
# ~/.config/kak/kakrc
# Enable line numbers on the left margin
add-highlighter global/ number-lines -relative
# Set tab width to 4 spaces
set-option global tabstop 4
set-option global indentwidth 4
# Use the gruvbox color scheme (if installed)
colorscheme gruvbox
# Create a custom keyboard shortcut mapping
# Map 'jj' to Escape to quickly exit insert mode
map global insert j '<esc>'
map global insert J 'j'
Community Plugins
While Kakoune is powerful out of the box, the community has built a lightweight plugin manager called plug.kak to handle extensions. Once installed, you can easily add plugins for Language Server Protocol (LSP) support (kak-lsp), fuzzy finders (fzf.kak), and enhanced syntax highlighting.
7. Conclusion: Is Kakoune For You?
Kakoune is not trying to be a direct drop-in replacement for Vim. It is an evolution of the modal editing paradigm.
By aggressively prioritizing visual feedback through its “Selection First” model, it solves the inherent anxiety of blind execution that plagues traditional Vim users. By treating multiple cursors as a foundational mechanic rather than a bolted-on plugin, it provides incredibly powerful tools for refactoring large blocks of code intuitively. And by delegating window management and scripting to standard Unix tools like tmux and POSIX shells, it maintains a remarkably clean, focused codebase.
If you love the concept of keeping your hands glued to the home row, but you want to see exactly what you are doing before you execute a destructive command, Kakoune is an absolute revelation. It takes a few days to unlearn your Vim muscle memory, but once the selection-first paradigm clicks, you may find it impossible to go back.
Frequently Asked Questions (FAQ)
Q1: How does Kakoune differ from Vim?
A: Kakoune flips Vim’s “Action then Object” grammar to a “Selection then Action” model. Instead of deleting a word blindly (dw), in Kakoune you select the word first (w) to visually confirm it, and then apply the delete action (d).
Q2: How do multiple cursors work in Kakoune? A: Unlike Vim where multiple cursors are often hacked via plugins, Kakoune is built around multiple selections as a foundational mechanic. You can use regex or line-splitting shortcuts to spawn cursors on multiple lines or variables simultaneously, making global refactoring highly visual and precise.
Q3: Does Kakoune have a built-in window manager like Vim? A: No, Kakoune explicitly rejects internal window management in favor of the Unix Philosophy. It operates on a client-server architecture, encouraging you to use external terminal multiplexers (like tmux) or graphical window managers (like i3) to split panes.
Q4: How do you write plugins or extensions for Kakoune?
A: Instead of using a proprietary scripting language like Vimscript, Kakoune integrates directly with standard POSIX shells. You can write plugins and complex macros using Bash or sh scripts to pipe text into standard Unix tools like awk, sed, or grep.
Q5: Is Kakoune available on macOS and Linux?
A: Yes, Kakoune is highly portable. It can be easily installed via package managers like Homebrew for macOS (brew install kakoune), APT for Ubuntu (sudo apt install kakoune), or Pacman for Arch Linux.



Discussion
Loading comments...