Cookies! This website uses Google Analytics cookies to track users visiting the site. You can opt in by clicking the button below.
Okay.

Inter Caetera

Vim's Small Idea

Six years ago Mike Kozlowski wrote one of my favourite articles on the Internet about Vim and approached the subject from a completely different side than most tackling this subject. In ”Vim’s Big Idea” he primarily compared the method of operation of Emacs-like text editors such as Sublime and Atom, to vi and vi-like editors (Vim, Neovim).

Where most tend to focus on ubiquity of vi, saying that it is present pre-installed on most operating systems, Linux boxes, Docker images and so on, the above mentioned article on how Vim works and, more specifically, how Vim’s language works. It’s quite odd saying that a text editor has a language, because, after all, we think of editors as very simple tools — you would be hard-pressed to find someone who finds Notepad the most robust and complicated piece of software on a Windows machine. And yet, there are a number of metaphors that, when observed from the vantage point of a long-time Vim user, find their roots in the heritage of Emacs and are not really obvious at second glance.

Consider a few of these metaphors. In an Emacs-like editor, you tend to always be in text input mode. That seems absolutely natural to everyone who uses computers these days — after all, isn’t the point of a text editor to input text? We don’t usually stop and think about the implications that this has, and it’s a particular quirk that has both its costs and benefits.

This is, oddly, not unique to text editors. When I was still a child I used to play a MMORPG called Tibia. One of the peculiarities of that game was the role that the in-game chat played. Aside from talking to other players, one used it also to talk to NPCs (for example saying “hi” “trade” in the vicinity of a merchant NPC allowed the player to sell and buy items) and to cast spells (saying “utevo lux” would cast the Light spell). Due to the importance of chat, the developers decided that it should always be focused, thus eliminating about 60% of the keyboard from practical usage. The rest of the control scheme were the arrow keys for movement, function keys for chat shortcuts (one could set the F1-F12 keys to automatically say something in chat) and the mouse for interacting with the game world.

It seems interesting in theory, but when you actually try this in practice you will quickly realise why this kind of control scheme hasn’t caught on. It only really makes sense when you have three hands. A lot is sacrificed when you’re always in text input mode, both in a MMORPG and in a text editor. Emacs-like text editors use complicated chords to trigger commands or, when considering particularly niche or rare commands, command palettes. All these workarounds are required because we make the underlying assumption that we have to be in text input mode all the time.

The default mode of Vim, on the other hand, is aptly named Normal mode. At first blush it looks similar, but when you press a button you will find that nothing happens and nothing new appears on screen. You can move the cursor around, either with arrow keys or movement commands. Since we are not in a text input (or Insert) mode by default, we have access to all letters and numbers on the keyboard. And so, typing w moves you forward a word, typing 0 moves you to the beginning of the line and so on.

The fact that we are not limited by the complexity of chords means that there can be a greater number of very idiomatic commands that correspond directly to what the user wants to do. For instance, I’m not sure if there is a command for “move to matching bracket” in most Emacs-like editors, but in Vim it’s just %. This quality of idiomatic and complex (as compared to Emacs) commands means that you can think in more abstract terms when inputting text, too. If you want to input text in a new line below the current one, in an Emacs-like editor you have to navigate to the end of the current line, press Return and then start typing. In Vim, you just press o.

This leads me to the final point — a very common criticism of Vim is that these commands are hard to remember. What one must understand, though, is that they are a bit like braille, they aren’t designed for the eyes, but for the fingers. Much like the letters of braille (or any other alphabet for that matter), when put together, they form a cohesive language that gets out of your way. Natural alphabets and languages get out of your way to let you grasp ideas and imagine stories, Vim’s alphabet gets out of your way to let you edit text at the speed of thought.

This quality: an idiomatic, muscle-memory-based and out-of-the-way approach to text editing is what I would call Vim’s Small Idea — compared to the Big Idea of composability of commands.

Inter Caetera

Inter Caetera is a blog focused on web development, quality, philosophy, religion and the humanities. Follow the updates on Twitter @inter_caetera