Hacking Thy Fearful Symmetry

Hacker, hacker coding bright

Gentlemen, set your keyboards to 'optimized'

September 13, 2006
perl vim

Yesterday, I decided to put in action two of the neato keyboard layout optimization tricks that I got from the the vim tips rss feed.

optimization 1: ( $caps_lock, $esc ) = ( $esc, $caps_lock )

In vim, one hits ESC a gazillion time a day and CAPS LOCK maybe, on two or three times a century. Yet, the first key is located at the outside periphery of the keyboard while the second sits, fat and proud, in the middle of things. Not fair. Well, doing a xmodmap escapswapper fix that engineering blunder, where escapswapper is:

! Swap caps lock and escape

remove Lock = Caps_Lock

keysym Escape = Caps_Lock

keysym Caps_Lock = Escape

add Lock = Caps_Lock

optimization 2: y/123456789/!@#$%^&*()/

When one programs in Perl, one gets to type '$', '@' and '%' six times per line (or more, if you're a Perl golfer or swear a lot in your comments). In comparison, numbers are used a wee bit less frequently. And yet, it's the symbols that get the shift tax. Not fair. Again, a little remapping easily corrects this gross injustice:

in ~/.vimrc

autocmd FileType perl source ~/.vim/my/perl_map.vim

and in ~/.vim/my/perl_map.vim

" map each number to its shift-key character

inoremap 1 !

inoremap 2 @

inoremap 3 #

inoremap 4 $

inoremap 5 %

inoremap 6 ^

inoremap 7 &

inoremap 8 *

inoremap 9 (

inoremap 0 )

" and then the opposite

inoremap ! 1

inoremap @ 2

inoremap # 3

inoremap $ 4

inoremap % 5

inoremap ^ 6

inoremap & 7

inoremap * 8

inoremap ( 9

inoremap ) 0

comments powered by Disqus

About the author

Yanick Champoux
Perl necrohacker , ACP writer, orchid lover. Slightly bonker all around. he/him/his