20120923

Editor Magic: emacs, vim, acme and the return key


Glenda, the Plan 9 bunny. Image copyrighted by Lucent Technologies, hosted by Wikimedia Commons and posted here for information purposes
A few months ago I wrote about how I'm using vim in my ipad. You know, I'm an emacs guy, just started writing my own (useful) stuff to improve it. Recently I finished gnusnotes.el, a package which allows you to easily add notes to emails. Of course, before this I had already written emacs code, just that it was only for me. A step ahead.

Anyway, back to vim. As much as I love emacs, I also love learning new things, and getting to grips with vim would improve how I edit and think about editing. So, I used it for a while, learning its basic usage. Then after a few weeks I had to edit some php, and emacs' php editing abilities are (at least until I configure multi-mode) below par. I used vim, so I got to use it more. So far, so good, its different but it also feels "right".

Now, a few days ago a post in Hacker News reminded me about an editor I wanted to check. For a few months I had a mental post it that read "Plan 9 from user space," the *nix port of Plan 9 from Bell Labs's operating system tools. I had used Plan 9 in a virtual machine many years ago (it was interesting) so I knew more or less what it was and how it worked. The post that made me remember it was A tour of the acme text editor by Russ Cox (of go-lang, among other things, fame) and as you may guess the editor was the acme text editor.

Acme is very different from other classic text editors (though acme is from the 90s, I think it is a "classic".) It is very mouse centric, which for an emacs and/or vim user is almost like... sacrilege. But it has a few neat tricks in its sleeve that make it quite awesome. A quick example: if you type in a buffer pdflatex thisfile.tex and selet this text with the middle button, you'll compile thisfile.tex If you type in your current file New and press the middle button on it, you will get a new buffer for a new file. And so on, and so on (give a look at the tour!) As you see, cool. But... how does it compare to emacs or vim?

I've been using it for a while. Far less featured than emacs or vim, without syntax highlighting, modes or beautiful indentation. Nothing. Anyway, I like it a lot. Why? Well, it feels a little like magic. Just click that and do something. I kept thinking about this feeling, this feels like magic. For me, emacs also feels like magic whereas vim does not (at least usually, sometimes it does). I kept poking "Why"? Your mileage may vary, but...

For me, the answer is the enter key. A lot of things in emacs can be done without ever hitting the enter key (search, buffer switching, generic commands, exit or edit something in the recent file list.) On the other hand, in vim quite a few of the most basic commands require a press of enter. Saving, quitting, searching are the first I can think about. Also, the way vim works can require enter with more frequency. For me, enter is the anti-magic key, it removes the feeling of flow asking for confirmation in situations I don't want any, just do it. Acme addresses the same workflow asking for a click (emacs and vim can work like this for file opening with dired or :e respectively.)

I will write again about acme, because I want to bring some of its capabilities to emacs, so I need to use it more thus I'll give you some more examples of usage as time goes by. Of course, emacs already has find-file-at-point (ffap) that opens the file at point... But asks for a press of enter. No way. I wrote my own simple version of ff-at-point, that works without asking for anything. I'm already using it in LaTeX buffers to open included files. I need to extend it to any kind of file and related files, and add execute-at-point. Stay tuned, if I ever finish it I'll post it here and in the marmalade repository.

Update: you can find the work in progress in my github
Written by Ruben Berenguel