I have to start this post by saying I’ve been a dogmatic Vim partisan since the 1990’s, when I started using vi on the Solaris and Irix boxen I had access to, and then on my own machines when I got started with Linux in 1994.
I flamed against Emacs on Usenet, called it all the epithets (Escape Meta Alt Ctrl Delete, Eight Megs And Constantly Swapping (8 megs was a lot then), Eventually Mangles All Computer Storage)… I couldn’t stand the chord keys and lack of modality.
Even once I got heavily into Lisp I still tried to stick with Vim, or tried LightTable, or Atom, or SublimeText. But then one day I hit a wall and Emacs (plus cider-mode and slime and a few other packages) was the obvious solution. Now I’m out there evangelizing Emacs (I’m writing this post in the Markdown major mode plus some helpful minor modes) and I figure I’d offer some advice for those looking to convert to the Church of Emacs.
Primarily, this post is inspired by a request I received on Twitter:
@canweriotnow Got any links for switching to emacs? macvim isn't working in yosemite so I figure I might as well give emacs a real shot— maɪk pətɛlə (@mikepatella) October 24, 2014
Instead of just compiling some links in a gist, I figured it was worthy of a blog post, so my seniors in the Church of Emacs can tell me where I’m wrong in the comments. But this is based on my experience converting from Vim to Emacs, so I’ll explain what worked for me.
Prelude is really a great way to hit the ground running. It provides a wealth of sensible default packages, fixes the color scheme, and configures your
.emacs.d config directory in a way that makes it easy to configure without breaking shit.
The install instructions are here and I highly recommend it.
UPDATE: I forgot something vitally important about prelude. Prelude comes with
guru-mode enabled by default, which disables your arrow keys and prods you to use Emacs default navigation commands instead (i.e.
C-p for up,
C-n for down,
C-b for left,
C-f for right). These commands are worth knowing, but I felt like I was being trolled when my arrow keys just told me what chord combination to use instead. (As an aside, Thoughtbot’s dotfiles do the same thing with vim).
So you have two options: one is to
M-x guru-mode to toggle it every session. The more permanent solution is to add the following to your config (if you’re using Prelude, it should go in
(setq prelude-guru nil)
Just my personal preference, but something I found really annoying when I got started.
As far as all those useful navigation and editing commands, emacs (naturally) has a built-in tutorial accessible from
M-x help-with-tutorial or just
UPDATE TO THE UPDATE:
Bozhidar Batsov (the author of Prelude) pointed out in this comment that the current default behavior is to warn when arrow keys are used, not to disable them.
I hadn’t noticed the change, which came in with this commit.
You can find the configuration options for
guru-mode in the README here.
Emacs for Mac OS X
I really like using the packaged app version of Emacs available from http://emacsformacosx.com/. It works great with Prelude, and doesn’t include the cruft that Aquamacs tacks on to make it more Mac-ish.
You get a nice packaged Emacs.app that follows OS X conventions, but is really just straight GNU Emacs.
So, this is a touchy subject for me. When I first switched I used evil-mode to get my familiar Vim keybindings in emacs, but I actually found it made it more difficult to dive into emacs. Evil-mode is actually impressively complete when it comes to imposing vim functionality over top of emacs, but there are still times when you needto hit
C-x k or
M-x something-mode and the cognitive dissonance of switching between them was just overwhelming.
So I’d forego evil-mode and just keep Emacs Wiki open in your browser for the first few days. It doesn’t take that long to dive in head-first.
It ships with Prelude, so not a major headline, but it does help to keep your projects organized and navigate files.
Since this is really about Clojure development environments, I might as well dive into the inherent Lispiness of emacs. The extension language is a Lisp dialect, and very easy to learn and use. Emacs is so extensible that one of the running jokes is that it’s a great operating system in need of a decent text editor. I’ll get to that later.
Interacting with Clojure is amazing with cider. You get an in-editor REPL, inline code evaluation, documentation lookup, a scratch buffer for arbitrary code evaluation, and a dozen other features. LightTable is nice with its InstaRepl but emacs/cider is the real deal. You cannot wish for a better Clojure dev environment… and the community agrees:
cider-jack-in connects to a
lein repl :headless instance, and
cider-mode gives you inline evaluation in any Clojure file. It’s amazing.
paredit and smartparens
Ever have trouble keeping your parens balanced? You’re covered. paredit is the classic solution, but a lot of folks are using smartparens instead… I’ve been using smartparens in strict mode and it’s made me a lot more disciplined about how I place my forms.
That joke about Emacs being an operating system? Not such a joke.
My favorite Twitter client right now is Emacs twittering-mode. There’s Gnus for Usenet and Email, and Emacs 24.4 just came out with an improved in-editor web browser called
Emacs is a deep, deep rabbit hole. The only way in is head first. But there’s so much you can do in here, and it’s a staggeringly powerful environment.
Welcome to the dark side. We have macros.