Computers Nov 28, 2011 on

I have been using Emacs for over a year now. I actually didn’t learn a lot when I started using it (just the basics to get going and then some relatively common keyboard shortcuts), but lately I have been reading and learning much more about it. I’m so grateful by everything I’ve learned from different people on the net that I wanted to share a couple of things I’ve learned, and a simple major mode for editing AsciiDoc documents.

As a long-time VIM user, I feel it’s my duty to make a micro-introduction to Emacs to VIM users (skip this whole paragraph if you’re not one of them). Emacs is so different than VIM that the comparison doesn’t even make complete sense, but Emacs does have many sweet, sweet features that might tempt VIM users. And let me make this clear: Emacs, in its default configuration, is rubbish. If you don’t like the idea of customising your editor, learning about it, discovering new tricks, “plugins” and shortcuts and maybe even writing your own extensions… use a different editor (eg. I find VIM way better than Emacs on the default configuration). Likewise, if you don’t learn VIM properly and don’t learn the gazillion shortcuts to fly around your code while you stay on the home row… use a different editor. With that out of the way…

A lot of what I’ve learned lately I’ve learned from a handful of websites and Twitter accounts, listed here:

In particular, things I have learned that I thought would be cool to share:

The zenburn colour theme. I didn’t really like any of the colour themes that come with Emacs. And although I did see solarized, I thought it looked like crap on Emacs (very different from the screenshots, maybe it only works properly on Emacs 24?).

hippie-expand is a pretty cool completion system, familiarise yourself with it.

If you code Perl, you should be using cperl-mode, not the default Perl mode.

If you code Javascript, you should be using js2-mode, not the default Javascript mode. Also have a look at my js2-mode configuration, you might want to do some of the same tweaks.

If you have to do anything with XML, make sure you use nxml-mode, including its awesome feature to validate an XML document against a schema.

yasnippet. Very cool snippet system. Just have a look at the EmacsRocks screencast on yasnippet.

key-chord. Allows you to assign shortcuts to “key chords” (two keys pressed at the same time). Very comfy esp. if you miss some VIM shortcuts and want certain operations more VIM-like. Also seen on EmacsRocks, and again just check out the EmacsRocks screencast on key-chord.

And speaking of VIM, have a look at iy-go-to-char, again seen in EmacsRocks (on episode 4). Hint: this works best when combined with key chords.