Der Blog

Oh no, not that old holy war again

A couple of days ago I came across this quote: "Perl by itself is an OK OS, but it lacks a lightweight scripting language". I was immediately reminded of something else I'd read about Emacs, something to the effect that Emacs was a decent OS (or maybe shell) but lacked a good editor.

Now, before I start a flame war, I'll admit that Emacs is indeed a stonkingly powerful editor. The other major hacker's editor, Vim (a modern, more usable version of vi), is also programmable, but not nearly to the same extent that Emacs is - not to mention that Emacs Lisp is infinitely better documented than Vim's scripting language. There are lots of add-on modules to Emacs written by people who want it to do something it couldn't do before, and it's easy to change its behaviour if you want.

So before I learned to use Vim (currently the editor I use for literally all editing tasks), I had a go at learning Emacs. But I could never get used to the strange choices for navigation keys (up, down, left and right are (using Emacs notation) C-p, C-n, C-b and C-f respectively, which are allegedly mnemonic, at least to English speakers, but certainly not ergonomic) or the fact that you have to stretch your pinkie to get to the Ctrl key to use them (this reliance on shift keys being the source of one of the jocular expansions of EMACS: "Esc Meta Alt Ctrl Shift"). When I got round to learning to use Vim, I found that using Vim was simply much more comfortable - up, down, left and right are k, j, h and l respectively, all on the home row (assuming a qwerty-ish keyboard - mine was UK qwerty at the time, now a German qwertz) and unshifted.

But I have sometimes thought that Vim was not flexible enough, that I wanted to tweak some quirk of the current syntax highlighting or indentation mode, and was rather put off by the unique scripting language. So I made a mental note to learn Emacs, but never got round to it because I was so put off by the editing interface. Enter Viper.

Viper is a vi major mode for Emacs. A major mode determines the meaning of all the keystrokes - there are Emacs major modes for everything from text editing through reading mail and playing Nethack to consulting a robotic psychiatrist. (As in Eliza, not Susan Calvin. No, I'm not making this up.) It just so happens that some people who would like to use Emacs prefer the vi editing interface, and so they implemented a major mode to make editing in Emacs more like editing in vi. So I'm investigating it.

The most obvious differences I've noticed so far between Vim and Viper are undo (pressing u a second time in Vim undoes another action; in Viper it undoes the undo) and visual mode (in Vim; it's equivalent to setting the mark, moving somewhere and doing something with the region in Viper, except the region isn't obviously visible like in visual mode). Presumably it uses Emacs bindings for moving between windows too, instead of Vim ones (the latter being quite orthogonal - to move to the window above, you type C-w k). Time will tell whether I like it enough to switch.

[ Entry posted at: Mon 22 May 2006 20:54:11 UTC | 1 comment(s)... | Cat: Geeky ]

Marcus writes:

Vim is great for finger-feel, but Emacs has the features. Viper is a good start, but to make it a little more Vim-like visit for some ideas.

And to make it completely tolerable, add this to your .viper:
(viper-record-kbd-macro "gg" 'vi-state [\1 G] 't)

[ Sat 08 Jul 2006 04:50:03 UTC ]

Add Comment

Validate : XHTML / CSS / RSS / ATOM