Kakoune
Starting with nvim
After years of starting and stopping I started working full time in nvim at the end of the last year. I watched a video from primeagen that inspired me and after a few iterations with lazyvim I ended up with my own config based on kickstart.nvim. I read Practical Vim by Drew Neil and had a great time ever since.
Reason for switching
The one thing I was missing was multiple cursor support as I was used to from my JetBrains IDEs. I came across helix, which was a modal editor like nvim but with support for multiple cursors.
- After trying it, I noticed the amount of pain I experienced in keeping my nvim config alive and updating it.
- Especially niche plugins that worked together were especially fragile (test runner, dap/debugging, lsp or even snippets.)
- Lua is an annoying language to write anything in.
I might end up using helix, if the plugin system ever get’s finished. For now I keep using kakoune, which is mentioned as one of the inspirations of helix.
Advantages of kakoune
Multiple cursors support
Multiple cursor are the central way of interacting with kakoune, everything is built around the concept. I think 90% of macro activity is done easier using multiple cursors. With the concept of filtering cursors it’s even better than JetBrains’. It’s even find and replace for me.
In the above example you would select all the structs, press s
to spawn a new cursor on every place that matches the regex you can type.
Let’s say you want to match every 32
.
I added <>
to indicate where this would add selections.
Change everything to 64, and select the prefix letter f
or i
and press alt-k
to type a new regex that will filter all current cursor selections to only keep the ones with i
.
This will result in this selection, ready to change to an unsigned int:
Object -> Action instead of Action -> Object.
This means pressing wd
to delete a word, intead of nvim’s dw
.
It’s just very convenient to see what you have selected before you are acting on it.
Client / Server
Every kakoune window is talking to the same server underneath. That means no conflict between your terminal multiplexer and editor that both want to spawn split windows. This one is so obvious after you try it, it surprises me this is not the default for all terminal editors.
Plays nice with shell commands
The |
key pipes the selection to a shell command, and replaces the selection with the output of the shell command.
Select json press | jq
and the selection will be formatted json.
Neat!
Want to sort? Use sort
.
MS Word style paperclip
Microsoft Word era paperclip suggestions, what more can you want?
Layout
I’ve made a script that splits my kakoune in three separate windows:
The bottom window is used for getting type hints from the lsp (similar to pressing <leader> k
in vim.
Except here it is dedicated to the bottom window and will stay around after navigating/typing.
You can tmux your way to that pane scroll or and yank text.
The left pane is dedicated to other actions like the result from unit tests, or a file tree to navigate files.
Plugins
Kakoune has been a while and some plugins I found where archived 4 years ago. But… Still work? It’s been very stable for me. List of plugins I enjoy: my config
- kak-lsp (language server integration)
- kak-tree-sitter (syntax highlighting)
- fzf-kak (fuzzy file finder / grep)
- kaktree (filetree browser)
- cargo-kak (rust integration / test runner)
Some small snippets I really like
- harpoon.kak (project based persistent bookmarking)
- web.kak (open code selections on github)
- symbol.kak (list all symbols in current project)
Some plugins use command line applications to do the heavy lifting. I use nix to make sure every package is reliably installed.
Active community
The discord is pretty small but really active with most plugin authors chatting there daily. Plugins for rust are great, for typescript / frontend work it’s not great though.