Kakoune, the Text Editor I Didn’t Know I Needed

Like the idea of Emacs and Vim but think it is too complicated?

If you are a software developer, you may have tried Emacs and Vim at some point in your life. If you are like me and kind of have a goldfish memory for complicated keyboard combinations, you would have given up on these editors already deciding they are too much work to learn.

I’ve learned the basics of Vim but never got efficient at using it. Instead my goto editor ended up being TextMate on the Mac. It tried to take idea of these two old Unix editor and bring them into the modern era.

So far so good, but I have lately found myself having to ssh into a Linux box. That is when you realize that a text editor working well in a terminal would be really handy.

I am willing to sacrifice some power for better ease of use. Kakoune maybe just that kind of editor. It is a sort of Vim replacement. It has made a number of design changes relative to Vim that makes it much easier to become productive for people who don’t want to spend lots of time learning Vim.

What I like about Kakoune

Vim has this powerful idea of combining actions. E.g. I can can hit to move a word or to move 3 words. I can prepend an action such as delete to combine actions, so , deletes 3 words.

Kakoune has taken this same concept and reversed it. So you write instead. That is you specify the objects (part of the text) you want to do something with and the action last.

This may not sound like much, but it makes a huge difference. Why? Because it allows you to see at all times what text you are performing a command on. Kakoune always highlights the text that will be affected by the next action. So if I hit , I will see 3 words getting highlighted. Hence there is no guessing game what words will be deleted by .

Maybe this does not sound like much to you, but once you start using it, you realize how much it simplifies everything. You can use any combination of commands to get text selected. Once the text is selected you can do a whole host of things:

  • Delete it
  • Replace the text with something else you write. Remember the cursor can be in multiple locations, so you can write replacement text for many locations in one go.
  • Perform a regexp search only within selected text.
  • Pipe selected text into a unix command and replace selected text with result. E.g. you can select a list of words and pipe the words into the unix command to get the text sorted.

Kakoune Feels Like a GUI App

What helps doing stuff, is that you get online help for some much of what you do. Vim and Emacs does not give this level of constant feedback. In many ways using Kakoune is like using a GUI app. The advantage of GUIs over command line interfaces is that they display all the options available to you. Kakoune is very good at showing you what options are available and what it expects from you. Whenever you start writing various commands it will tell you what it can complete to, and what possible arguments it takes.

For people like me with Goldfish memory when it comes to advance text editors this is a big advantage.

Setting up Kakoune on Mac

To install it I just use homebrew.

$ brew install kakoune

Part of the reason I am writing this intro, is because of one really annoying thing I spent a lot of time to figure out, and that is to get the alt key to work in Kakoune. Without the alt key a whole bunch important stuff will not work. Go to preferences and check the "Use Options as Meta key" checkbox, as shown below.

Image for post

Now you can edit a file by writing in the terminal. E.g.

$ kak somefilename.txt

You can configure this for iTerm2 too if you use that instead. For left and right option key, you need to select the option as shown below.

Image for post

Most Useful Keyboard Commands

You can find extensive documentation of all the commands here on the official site. So instead I will focus on explaining how to read the docs and what are the most useful keyboard commands to get you started.

The documentation will write keyboard commands like and . If you are a bit slow on the uptake you, like me, you did not immediately realize this means and . So means or key, while a capital letter means you need to hold .

So here is my list of commands according to need.

Absolute Basics

  • That means the Escape key. Use it to enter command mode. You need to get into command mode first if you want to exit the program, or issue any other commands.
  • Exit Kakoune. If you don't want to save, write .
  • Save file you are currently editing
  • Insert text at current cursor location. This throws you into insertion mode or writing mode, whatever you may call it. It alls you to actually write text in the file. To get back to issuing commands again hit .

Navigate and Select Text

A lot of these commands are used to navigate and select text. But remember you can use the key to add to the selection. E.g. each time you hit that jumps one word and selects that word. The previous word becomes deselected. However if you hold and hit three times, you will end up with 3 words elected. So selects 3 words.

  • jump one word forward and select it.
  • jump backwards one word and select it.
  • one character back.
  • one character forward
  • jump to beginning of line and create selection from current position to beginning.
  • jump to end of line.
  • Select all text.
  • Deselect selection. Useful if you got multiple cursors.


  • Undo last edit.
  • Copy (yank) current selection.
  • Past what was copied.
  • Uppercase selection.
  • Lowercase selection.

Search And Replace

  • Search for a text. You can use to compete words, instead of writing them out fully. Readline keybindings also work so, you can use e.g. () too delete a word you wrote. and to jump to beginning or end of text.
  • Look for next matching text searched for with
  • Previous match. So reverse of .
  • Substitution using Regexp. You need to select some text to apply this to first. Remember you can combine this. You can write "foobar" to select all occurrences of "foobar" within the selection. Hit enter, and then to make "foobar" into uppercase.

Programmer Specific Selections

As programmers we often deal with code grouped in between parenthesis, braces, quotes etc, and we want to treat these blocks of code as a unit. Maybe you want to move a block of code or delete it. That means it is handy to be able to easily select it.

The way this works is:

  1. Decide if you are selecting the whole block or just one side. E.g. do you want the selection from your cursor position to the left side?
  2. Decide what sort of block you are selecting: a word, a string, code between curly braces etc.

Some useful commands and keys:

  • Chose to select all text to the left of cursor until start of block.
  • From cursor until end of block.
  • From start to end of block.
  • Press either of these to select the code within this type of braces or parenthesis.
  • Alternative for selecting parenthesis
  • Select a word. E.g. if the cursor is in the middle of a word, , will select the whole word.

Let us look at a bigger example. Assume you are in the middle of block at:

(egg spam (bar foo bar) chicken)

And want to select the whole then you hit: , .

Written by

Geek dad, living in Oslo, Norway with passion for UX, Julia programming, science, teaching, reading and writing.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store