Archive for July, 2007

Emacs newbies – don’t swap Ctrl and Caps Lock

Monday, July 23rd, 2007

Newcomers to Common Lisp are encouraged to use Emacs (see also Finseth) so that they can use the fabulous Slime (and one should not forget paredit) as a development environment. Those that don’t insist they’ll stick with Vim (and then unaccountably fail to develop slim-vim), or try Cusp, will at some early point be advised to swap their Control and Caps Lock keys to save wear and tear on the pinkie. Even EmacsWiki points to typically forthright Steve Yegge piece which leads off with this advice.

I say – No. The proper place for the Control key is not “on the home row” but on each side of the Space Bar, where Tom
Knight and the mothership intended them to be. And outside the Control keys should be the Meta keys, and outside them should be the Super keys, and finally the Hyper keys. This allows for what I think is a very natural way of typing key-chords – the modifiers with one hand, and the letter/symbol with the other. These are, after all, the sorts of keyboards on which Emacs was first developed.

How you do this will depend on your OS and your keyboard. For Windows, you might like to start here or here.* In OSX you can look in System Preferences > Keyboard & Mouse > Modifier Keys. For Linux, there are a thousand xmodmap and xkb tutorials…

The other keyboard reconfiguration I recommend is, where possible, to put the parentheses on unshifted keys (swapping with the [square] brackets works on some keyboards). Of course, if, like me, you live/work in a locale with all manner of chicken scratchings on top of proper latin letters this may not be possible or convenient. (Eric Naggum’s more radical approach can be seen here.)

So, my advice for Emacs (Climacs, VBacs) newbies would be: don’t swap Caps-Lock and Control, swap Alt, Ctrl, Windows, Application, AltGr…

* For example, if my Windows XP notebook had the following key configuration to the left of the spacebar
(from right to left, inside to outside)
Alt Windows Ctrl and I wanted it to be Ctrl Alt Windows, I would do the following:

  1. Fire up regedt32.exe and navigate to HKEY_CURRENT_USER\Keyboard Layout.
  2. Create a new entry Scancode Map (using Edit > New > Binary Value).
  3. Edit the new entry (using Edit > Modify Binary Data) to contain the following:
        0000   00 00 00 00 00 00 00 00
        0008   04 00 00 00 1D 00 38 00
        0010   38 00 5B E0 5B E0 1D 00
        0018   00 00 00 00

    The table is in little-endian form. The first 8 bytes are header (all zeroes). The next four bytes contain the count of entries (4, including the sentinel). The three following four byte entries swap Left Alt (0x38) with Left Ctrl 0x1D), Left Win (0xE058) with Left Alt, and Left Ctrl with Left Win. The last 4 bytes are a null terminator/sentinel.

  4. Close up, log off, log on, and enjoy.

If you did this, of course, it would be entirely at your own risk.