Modal editing means you have different modes while you edit a file. For example, in vim you start in “normal” mode. In this mode you can move around a file, search for things and much more. Pressing i in normal mode puts you into “insert” mode. This is the mode you’re used to in most editors, typing a letter inserts it into the document.

This is incredibly powerful because normal mode provides us with a sophisticated language for travelling around and mutating the document in a predictable way.

For example, given the following lines:

let a = 5;
let b: i32 = 10; // this is a comment

If we wanted to come up with a set of keys that would take us to the number on the current line, regardless of what line we are currently on, we could do so with the following keys:

^f=w

  • ^ go to start of line
  • f= find character (= is the argument)
  • w go forward a word

In vim, we could create a macro (save a sequence of keys that can be replayed) and repeat this macro by pressing a single key. A macro is essentially a function, where ^f=w is the implementation, and the text & current cursor position are the input.

Kakoune takes this a step further by also giving us multiple cursors. It’s the same concept, but in this case it’s more like stepping through the “function” piece by piece. Each time we press a key we can see how it interacts with each line, and if we mess up there are mechanisms to “step backwards” and try again.

That isn’t to say you can’t achieve similar results in non-modal editors. Emacs, for example, provides a similarly complex language for interacting with text by using modifiers such as <alt>. In general, most editors do not provide you with the variety of tools that editors like vim, kakoune and Emacs do, whereas most modal editors will.