Emacs as a Vim user

Four months ago I decided to learn Vim and began using it as my full time text editor at work and at home. I’ve gotten pretty damn comfortable with it. I don’t know if using Vim has made me faster or more efficient, but there’s definitely a flow that comes from using the keyboard for everything.

As I mentioned in my earlier post, one of my main attractions to Vim has been the idea of Vim as a language.1 I’ve learned and internalized the grammar of Vim, and there’s no going back from here. Text objects, for example, make Vim super powerful for HTML and CSS.

A few weeks ago, something happened. Something that almost made me switch back to Sublime Text that same day: David Jonathan Ross released Input, a font family designed for coding. There have been a lot of fonts designed for coding, but what made me notice Input is that it includes a sans serif. As a typography geek, I just had to try it.2 I couldn’t. Since I run Vim in the command line, trying to use a non-monospace font was a dead end. Even MacVim — as far as I can tell — is limited to monospace.

I love good typography so much that I seriously considered going back to Sublime to try Input. I tried it for a day, but Sublime suddenly seemed so clunky. Having to use the mouse to navigate to the inside of an HTML tag instead of just pressing cit wasn’t going to work. I tried Sublime’s Vintage Mode and Vintagenous but found them buggy and insufficient. I admitted defeat and switched back to Vim settling on Input Mono. It wasn’t over though.

I had an inkling that Emacs could handle proportional fonts and for a while now, I have been seeing mentions online of people switching from Vim to Emacs with Evil. I was curious. Maybe the endless tinkering hacker side of me got too comfortable with Vim, maybe it was Input Sans. I had to try it.

I set up Emacs with Evil. Evil is an implementation of Vi for Emacs, and it’s incredibly thorough. Text objects, macros, the ex :normal command — it’s all there. I was immediately comfortable.

I haven’t fully made the switch yet, but I’ve been tinkering with Emacs for about a week now, and I’m getting close. I tried out a couple starter kits to get a feel for where it all goes, and learned the basics of elisp.3 Then, I started from scratch. The learning curve is steep, but I’ve been having fun setting up my own .emacs.d this weekend. My goal is to understand everything that goes into my config.

I’m very comfortable and productive with my Vim configuration, so my first step has been to replicate the most useful features of it in Emacs. I was happy to find Evil ports of a couple of my favorite Vim plugins (surround and sneak), and I’m experimenting with projectile as a replacement for CtrlP. I’m also starting to explore the improvements that Emacs can bring to my worklow.

TRAMP mode could prove to be very useful. Tramp allows you to transparently edit remote files via SSH, treating them like local buffers. I’m using Tramp right now to write this post directly on my VPS in Writeroom mode.

My motivation for learning Vim in the first place came out of having to use a dozen different machines each week at work. My workflow since switching to Vim has been to clone my dotfiles to each machine I was working on and keep a tmux session running. This works well, although some machines had outdated versions of tmux and/or Vim and I’d have to deal with it or compile my own. If I could replace all of that by using Tramp from my laptop, that’d be swell. Not a huge improvement, but perhaps a slightly prettier and easier centralized workflow.

I don’t know yet if using Tramp is feasible for Magento projects because I’m constantly switching between files and there are over twenty thousand files in a Magento install. My Vim solution was to set up two CtrlP shortcuts for the two directories I actually care about. I’ve done something similar with projectile but it’s significantly slower over Tramp than in Vim running directly on the server. But we will see. Either way, super handy for quick remote changes and instances where I don’t have to switch between twenty Sass partials and template files.

Another sticking point with Emacs has been Git. Magit is good, but Fugitive for Vim is really good. I have four leader keys for fugitive that I use all the time: gs for status, ga to stage the current buffer, gc to commit the current buffer (I just type the commit message and hit enter), gp to push, and gm to amend. I like to commit frequently, and this makes it super quick. I can stage and commit within a couple of seconds without ever leaving the buffer. With magit, it seems that you have to open the status window to stage and commit changes. No biggie: it should be pretty easy to write something on top of magit that’ll be as fast as my Vim workflow, and I’m already half way there.

I’m not sold on Emacs yet, and I’m still more productive and comfortable in Vim at this point, but it’s been a fun experiment.


  1. I’ve recently learned that the vast majority of the stuff I use every day that makes Vim awesome comes directly from its predecessor, vi. Vi has been around since 1976. My neckbeard grew significantly while writing this footnote. 

  2. Monospace fonts have been used for programming since the beginning of time, and I had never even considered not using them.

    Still, David makes a strong case for proportional fonts in coding. And Input Sans is just so pretty. How could I not try it? 

  3. Emacs lisp is the dialect of lisp used to customize Emacs. In fact, most of Emacs is written in elisp, which is what makes it so extensible. This is very intriguing to me. If Vim is a grammar, Emacs is more like creating your own grammar.