Considering a Switch from Vim to Emacs?!

People joke about that I change my blogging platform and editor of choice only to have something to write about. And I guess I change both more than most people. My changes of blog engines may be a subject of another post.

My recent adventures in Emacs have been caused by two things.

I am on a two week vacation - and I usually use that to brush up on some sort of tech, programming language, framework, tools or techniques. (Apart from being with my family of course)

I have heard (ok, I read on twitter) from a couple of sources that Spacemacs may be a great way to transition to Emacs from Vim

Flirting with Emacs

I have been trying out Emacs a couple of times in the past. But it has never really caught my attention enough for me to warrant a deep dive. I have always found myself immensely slower in Emacs than in e.g. Vim. My previous attempts at looking at Emacs have always been with a fairly vanilla setup of Emacs. This time around though, I have started with a crazy amounts of default packages. (Much in the vein of Janus for Vim).

A history of editors

For context - I have decided to quickly write about the editors I have used historically.

Starting out: notepad (1997)

Yeah, I’m that guy. I starting writing code (primarily html and ASP) in Notepad on a windows machine.

First real editor: homesite (1998/99)

I tried a couple of editors in the late nineties. I don’t remember many of them - but homesite is one of the earlier ones.

I used this editor to write a very simple ASP based cms in our web company 9iA. Maybe cms is a bit of a strech, but it allowed people to change content on a website, without using html.

Visual Studio (2002-2007)

Our company jumped on board the .net train as soon as it was released. I think we bought a VS license only a month after it was made available. And I took a deep dive into the .net framework. And it was a big change from the ASP way of doing things. We spent a couple of months developing a new cms called i-update. This “cms” actually had some features (not just being a database editing tool for static inclusion of content into html pages). It had templating, xml based menu system, dynamically generated breadcrumbs and a html editor component (which we bought a license for from aspose iirc).

Funny anecdote: last year a customer having run with this “cms” a couple of years called my former collegue, because they could no longer login.

I loved Visual Studio - and for a lot of years after using it it was the benchmark for all other editors.

Eclipse/Netbeans/Aptana/Zend Studio (2003-2007)

Our company dropped creating our own cms in 2004. We went from three people to only two, and we could no longer afford for me to “just develop the cms”. I needed to develop customer features that we got paid for. We decided to throw all our time in the TYPO3 cms, and shifted our focus from ASP.net and microsoft windows, to PHP and Linux servers. Within a couple of years we had a lot of sites hosted on servers we rented and I ran into Emacs, vim and pico a lot of times in these servers. (And both Emacs and Vim got a lot of hate from me - mostly because I did not know how to either open, save or close files - let alone quit the editor).

For development though I switched a lot between Eclipse and Netbeans. Both were too slow, and PHP support were bad in both in the beginning. It was kind of an arms race at some point. Eclipse got more and more features for PHP, especially because both Aptana and Zend Studio was based on them.

I switched to Aptana as soon as it was released - and at some point in 2007 I switched to Zend Studio

Switch to Mac: TextMate (2008)

In 2008 we closed our company and I got a “real job” at a small web company in Aarhus which only had mac computers. I was pretty much forced to switch. I hated it for about a month. Then I discovered TextMate - and I was in love. TextMate became my primary tool for writing code which now consisted of both ActionsScript and JavaScript as well as PHP. Websites were still based on TYPO3.

New job, same tools (2008/09)

Late 2008 I switched to my current job (damn I’ve been here a long time now). When I began I was the only developer. I used Zend Studio and TextMate. I could not shake the need for an IDE for my php code for some reason (which was pretty weird since I never really used any IDE features, apart from the code completion).

PhpStorm Sublime Text (2011/12)

In 2011 we started a new project, and got another developer (a former colleague from my first job above). We decided to get PhpStorm (after me having tried the IntelliJ platform for some java projects and having tried the trial of PhpStorm and being pretty impressed). The project was released in august and a couple of months later 3 new developers were added to the company - and I was contemplating switching completely away from PhpStorm and using Sublime as my primary editor. As a consequence all developers got a license for both, and were left to decide which one they would use on their own.

I kept using Sublime more and more, installing packages - and making my own. It was like being in love with TextMate all over again. However I found it much easier to extend and tweak, and I began experimenting with the vim mode.

A Meetup that changed my (editor-)life

In spring 2012 I was prasing Sublime Text as the ultimate editor at a meetup (a lighting talk iirc). @greystate in turn praised TextMate (I knew he would) - I think he still uses it. And @bewildergeist presented Vim. He outnerded my on my own turf I felt. He had some great points - and all the things he showed was exactly the things I wanted from an editor. And even though I tried to persuade him that vim mode in sublime was awesome - he insisted that I should try it, and then decide. And I decided that day, that I would give vim a real go. But instead of going the all-in-route with Janus that @bewildergeist had presented - I started with an empty vimrc, and started picking the best parts from other peoples dotfiles.

Vim (2012-2015)

I had a hard couple of months ahead - but my productivity in my editor skyrocketed - to an extent that a couple of colleagues at work also started changing to vim. (At some point my dotfiles was hailed as both evil and good). Evil because it had same insane defaults (e.g. disabling arrow keys, and forcing you to used hjkl). Good because it forced you into the vim way of thinking - and while it was hard to get started - you quickly became rather good at it.

All the things I love about vim: modal editing, easy customization, quick navigation in projects, files, buffers and windows and first and foremost speed is now a must for a new editor. And vim keybindings for “normal” mode is pretty important too, because I am not ready to take months out of my life to learn a completely new way of navigation a document.

In this period I shifted from doing Php/JavaScript/Html/css only to also programming in: Ruby, Python, C, C++, Go, Objective-C and also looking at a lot of other languages from time to time. And for almost all of them vim had either built in support, or it was very easy to find a plugin that added the needed functionalty.

AND NOW: Emacs again

Spacemacs is awesome. Enough said. It has all the features I need from vim (by using evil-mode which have drastically improved since last time I tried it out) but also makes a lot of sane defaults for Emacs in general. Including using evil-leader (which is mapped to space - spacemacs gets it’s name from that) which maps a lot of commonly used commands to an easily navigated mnemonic-based keyboard shortcuts menu system. (If you press slowly, you’ll get hints about what keys are available). This reduces the cognitive overhead in shifting to emacs to a minimum.

But if this was all - vim would have been good enough. What are the great things about having Emacs:

Spacemacs the good parts

Most of spacemacs features are just the same as the stuff I use in vim. Even though I have a lot of plugins installed in my vim setup (more than fifty last I counted) - not a lot of them get used on a day to day basis. The default emacs packages from spacemacs cover most of my needs. (I will share my customizations as soon as have found a way to make that work with both spacemacs and my current dotfiles repo)

Org-mode: hands down emacs’ killer feature

I have not had OmniFocus opened since shifting to emacs. I LOVE org-mode. It is a outlining tool, a task manager, a calendar, a blogging tool … it can do a lot of things. If you want more control over e.g. your gtd workflow (assuming you have one) org mode has so many features and settings that anything you want is possible.

I use org mode for my “new omnifocus” setup. Since everything is placed in flat text files (with a special format) it is easy to integrate into existing tools.

(at this point I had three paragraphs written, which are gone now because of a emacs crash!!! Damn! That has - almost - never happened to me in vim)

Lisp: Configuration and extension

I have always wanted to learn a lisp dialect. Now I have to. All settings are in lisp. Yes even stuff like “set this default value to something” is a lisp construct, and not a “variable = value”-kind-of-thing like in vim, and other editors. All extensions - pretty much everything - is in lisp. But getting to know lisp this way is great for me (and honestly I never learned python before starting to use Sublime Text).

I have allready made a spacemacs layer with a couple of custom functions and keybindings making my life with especially my gtd setup in org mode easier.

Speed

Emacs is faster than vim. Hands down. Well except for startup. Emacs takes approx 3 seconds to get ready, and vim (even with all my plugins) have never taken more than a second. But honestly how many times a day do you open a new editor?

I have still made vim my default editor on my system - which means that for these kind of single file editing sessions (e.g. git commit) vim is still my preferred tool - only because of the increased startup time for emacs.

On top of that - I am currently using the emacs.app instead of terminal emacs. The only reason for this for me is that I cannot for the life of me get copy/paste to/from osx clipboard to work in terminal. And I think the UI looks a little better in the desktop app as well. But I may be hallucinating.

Spacemacs the bad parts

Bugs

I have found more bugs in an editor the last week, than I have in all my time in vim - where I did not know what caused it, and/or how to fix it.

The primary things has been:

suddenly tab stopped working in insert mode. (an update fixed it though)

f[char] jumps did work in normal mode. (though F[char], t[char] and T[char] worked fine). Also fixed by an update

sometimes the powerline bar in the bottom doubles, and everything in the current buffers renders wrong (you know the thing that a forced repaint fixes in vim). My only solution to this so far has been to make a vertical split, and close it again. I have not seen the issue much these last two days - maybe it has been fixed.

three random crashes (the last one while writing the above lost paragraphs)

a couple of times vim keybindings are completely gone, and either my editor does not work as expected, or my emacs-fu is too underdeveloped to get back. Until now, the solution has been a ctrl-x ctrl-c (force close emacs)

Smaller user base

It feels like the amount of emacs - and especially spacemacs - users are much smaller than vim users. Maybe this is just something amongst my peers. But I have yet to find someone using emacs as their primary editor in my closest network. (I’m kind of a editor-hipster you know).

The smaller user base means that the amount of blog posts about the issue you could run into is much smaller - and often times a search for some problem in emacs just gives you the documentation. Luckily it is almost always well written - albeit a little on the “look at my big brain”-side of things.

Spacemacs customization

In the beginning I had a hard time figuring out where my customizations should go. Now I am pretty confident that I have found the best way for this. Most of my customizations are in my own spacemacs layer (.emacs.d/private/personal) and all my keybindings have been prefixed with o since it was not used yet by anything (and the first couple of keybindings I made was for org-mode so the o made sense to me).

Adding packages is done .spacemacs, and so is some customizations. Hopefully I will have a complete grasp of all this in the near future to give you a complete walk through of all you need to know to get up and running with spacemacs. (Especially if you are comming from a vim background)

Is Emacs my primary editor now?

I started this blog post a week ago, and at that time I was not really sure. Now I must say I am a convert. Damn!

Lets see if vim will get me back at some point.

Related Posts