← back to all talks and articles

Switching from Vim to Emacs

Recently I decided to switch from Vim to Emacs as my primary text editor. It took a little time and effort to get used to a new tool used as frequently and intensively as an editor. Here’s how I made the switch.

Advanced text editors can have a steep learning curve, so it pays to invest in learning to use it well. I find this to be both personally rewarding and a dangerous to learning and innovation: a form of editor Stockholm syndrome might make you blind to your current setup’s faults and overestimate its strengths. As with programming languages, human languages, keyboard layouts and many other subjects, stepping out of your comfort zone and learning something new can be quite fun, inspiring and challenging.

My Text Editor Shopping list

I’ve tried switching from Vim to Emacs before, unsuccessfully. This time, rather than just dumping in, I got it to stick with a plan: I drew up a list of what my editor should do, I researched how to do it with Emacs, and I arranged my setup as such.

This is roughly the shopping list I made before switching:

Some of this stuff is standard in most decent code editors, but I knew I had to find solutions that worked for me in these areas to be able to make the switch really work.

Notable settings and packages

I found some good packages to check off some of the items on my list. In no particular order, here’s what I use:

Emacs also comes with fine out-of-the-box support for:

I researched these options and packages mostly by trying out some of the complete configurations for Emacs that are available, such as prelude and spacemacs. Once you get a feel what’s possible, you can erase it all and start building your own, custom configuration. You can find mine in my dotfiles at Github.

Pros and cons

After a couple of weeks of working with Emacs, I think I can draw up a list of what I do and do not like about it. First, the bad things:

But here’s the stuff I do like:

Extensibility

Emacs is extensible with a decent programming language (a special flavour of Lisp). That means that I can make it do what I want it to do, but also that its plugins can have a lot more power than in other editors. Magit and evil-mode are good examples of the level of customisation that Emacs allows. Also, Emacs comes with a built-in package manager for plugins, which has worked fine for me so far.

Implement all the features

Emacs feels more like an IDE than Vim. Vim is built to be used as little as possible, so it’s fast and delegates as much as possible to regular shell programs. Emacs is designed to be used as much as possible, and comes with a shell built in so you hardly ever need to switch away from it. This makes for a nicely integrated experience, such as with Alchemist for Elixir. Also, with Emacs, I have no need for Tmux for asynchronous tasks like I do with Vim.

Emacs can do a lot of stuff; you don’t need all of it every day, but it’s great that it’s there when you do need it. One such example is C-M-T to switch two words or arguments. Another one that I find surprisingly useful is the ability to connect to a database and have a SQL prompt right there in your editor.

Getting started

It’s easier to start with Emacs than with Vim, with its modal editing — although I bet Emacs is harder to master than Vim is. It seems to require much less initial configuration than Vim to get something workable, even though you do have to learn lisp first.

Undecided about Evil-mode

I decided not to use evil mode (basically Vim in Emacs) so I could go all-in on Emacs. At the moment though, I’m still contemplating adding it to my setup because Vim’s modal editing is just so nice and speedy. But overall, I’m quite satisfied with my new workflow of running Emacs all day everyday, rather than juggling Vim instances and shells in Tmux panes.

Conclusion

Switching editors has been fun and inspiring so far, and I expect to learn much more as I go forward. Emacs has surprised in some regards, and disappointed in others — as was to be expected. You should definitely switch to Emacs if you like tinkering with your setup and integration with your tools. If editing speed is your thing, stick with Vim. But definitely try them both — if only for a fun challenge!

Arjan van der Gaag

Arjan van der Gaag

A thirtysomething software developer, historian and all-round geek. This is his blog about Ruby, Rails, Javascript, Git, CSS, software and the web. Back to all talks and articles?

Discuss

You cannot leave comments on my site, but you can always tweet questions or comments at me: @avdgaag.