Although the holiday season is sort of officially over (with Dreikoenigstag, on the 6th), I thought to sneak in a post whose title fits to the holiday season, and whose contents could be a tiny gift to some touch typists working on the command line.

Of late, I have started creating keyboard shortcuts that keep my fingers close to the home keys. This is especially useful as I use different keyboards during the day, each of which have different layouts for some crucial keys. I also don’t like reaching for things like escape, or the number keys, which are needed for Perl programming (e.g. 4-$).

My .vimrc file contains the following custom mappings. ‘:imap’ tells vi to interpret the first set of keys (e.g. ‘;x’) as another (‘escape + dd + insert’). Just add the mappings into the .vimrc file in your home directory and you can try them out. One thing you should do, though, is create an vim alias that points to a plain .vimrc file. That way you can paste in text that contains the mappings that you’ve created.

The first set help with general editing tasks. One of the main advantages is that you can do lots of editing without having to exit edit mode. I find this to be much faster than hitting escape, and then the appropriate key(s).

The second set turn vi into a poor man’s Eclipse. I’m sure there are other tricks one could use to save even more time (and there are others I haven’t shown, as they are not obvious and might only be of use to me).

You can also add the following to .inputrc and get keyboard shortcuts in any shell that uses the Readline library.

For example, the first one will create the R assignment operator with little finger movement. Apparently, the terminals on which R was developed had a key for ‘<-‘, so it wasn’t as awkward to use then. I do agree, as per the Google style guide, that ‘<-‘ is superior to ‘=’ (even from a purely aesthetic viewpoint). Happy typing!