Descent into Evil

13 February 2021

I've been using Emacs for over 20 years, ever since a friend at university persuaded me to install Linux and pointed me to Emacs as a text editor. In all that time, I've never used Vim. I was never religiously opposed. More an accidental Emacs zealot, through trying Emacs first and never having any particular reason to remove myself from the category of people who have to look up the most frequently asked stackexchange question of all time when they run crontab -e under a new user without remembering to first set EDITOR.

But a few months ago, on one of those random internet walks where you start off looking up the Artin-Wedderburn theorem and, half an hour of link-following later, find yourself reading an article on worm composting without any idea how you got from one to the other, I found myself reading the Vim manual.

I already knew about the model editing and hjkl keybindings. But Vim's composable commands had completely passed me by. This notion of Vim as a text editing language, composed of "verb" operators and "noun" motions or text objects, intrigued me. Over the following weeks and months, I found myself reading ever more blog posts and articles discussing the philosophy and design of Vim.

However, there was one thing I was never going to do. No matter how elegant the philosophy of Vim's editing commands, swapping Elisp for Vimscript was a Faustian bargain so offputting, I wasn't even tempted to fire up Vim itself out of curiosity. But there's a Goethian Gretchen to Vim's Mephistophiles: evil-mode – an implementation1 1People generally call it a Vim "emulation". But "implementation" seems more accurate to me. There have been many implementations of Vi over the years, such as Vim itself, just as there have been many implementations of Emacs. Under the hood, evil-mode doesn't just replicate a large part of Vim's command set and features.2 2Far more comprehensively than the superficial Vim keybinding emulations you find in many IDEs. It implements so much of Vim's underlying design philosophy in Elisp, it's closer to a new Elisp implementation of Vim. of Vim within Emacs itself.

Thus began my descent into Evil.

This isn't a post about Vim's design philosophy – you should read what others who know Vim much better than me have already said and written on that subject. Nor is it a post about how to install and configure evil-mode – Emacs isn't called the self-documenting editor for nothing! This post is about beginning my personal journey to craft Emacs + Vim into the perfect text editor.

Evil configuration philosophy

There are two schools of thought when it comes to configuring Vim. The first is very familiar to Emacs users: use its flexibility and configurability to customise Vim to your needs, accumulating an ever longer .vimrc file over the years. The second school of thought says: stick with the default configuration, so you'll be right at home whenever you ssh into a remote server and fire up Vi(m). I'm by no means dismissing this second school of thought. It makes a lot of sense if you're a sysadmin, and are frequently logging into and working on other servers and systems (or even routers and embedded devices) than your own.

I'm not a sysadmin. I almost exclusively work on a few computers that I have full control over and can configure however I like. In 20+ years of Emacs usage, having a hefty .emacs file and running a heavily customised Emacs hasn't been an issue. So after careful thought, I decided to allow myself to customise and configure any and every aspect of evil-mode, without regard to Vim defaults, and attempt to craft my own, personal, perfect text editor within the Emacs operating system.

It's an old joke that Emacs is a great operating system, lacking only a decent text editor. Like most jokes (and much of this blog post), that's not entirely fair. Emacs is a very good text editor compared to everything else out there…except Vim. Vim's combination of modal editing together with composable commands as a text editing language, turns text editing into a cross between precision surgery and conducting a symphony. I'm still a long way from having the Vim commands "in my fingers", and I'm still significantly slower at editing in evil-mode than vanilla Emacs. Yet even when all I'd done was read blog posts about Vim, before I'd even enabled evil-mode for the first time, I could see the potential.3 3Perhaps it helps that I've used Emacs for so long, and coded more Elisp than any other programming language4 4Not that I've coded vast amounts of Elisp compared to others. But, despite sitting in a Computer Science department these days, in my "day job" as a mathematical physicist, I prove things with pencil and paper5 5Or chalk and blackboard.6 6Or rather, pen and whiteboard in my current university office, sadly.7 7Or rather, just pen and paper in my current covid home bedroom-come-office, even more depressingly. far more often than I need to code anything. that it's probably the language I'm most comfortable programming in. When I hit Emacs' pain points as a text editor, I'm fairly sure the pain isn't because I'm unfamiliar with Emacs, or scared of diving in and coding up some Elisp.

But, even viewed purely as a text editor,8 8Let's not get started on Vimscript versus Elisp…! Vim doesn't get everything right in my not-so-humble opinion.

In this blog series, I plan to document how I turned Emacs into my own personal brand of Evil.

  • Evil cursor model
  • Evil keybindings
  • Evil search highlighting
  • Evil macro repetition

Leave a comment

All comments are moderated. Clicking submit will open your email client and let you send your comment by email. By submitting your comment you agree to license the content under a Creative Commons Attribution-ShareAlike 4.0 International License.




Creative Commons License