The Most Aggressive
Keyboard Customisation
in the Town
Part 1
Hardware
First of all, I decided to use KINESIS's Ergonomic keyboard as my
input device. It looks like this.
As a matter of fact, it is a little bit big for my hands (I am rather
short; I was too lazy to grow up into a tall man), but much better
than ordinary keyboards. Especially, it is a good thing that some
frequently used keys, e.g., Back Space or Control, are assigned to
thumb fingers. Thumb fingers have high motion performance and it is
simply a waste to use them only for space bar.
For the details of Ergonomic keyboard, see
KINESIS' web page.
Using XKB
Second, I decided to modify the layout of command keys, i.e., keys
with Control or Meta. Emacs is a very powerful editor, but its
command key layout does not seem ergonomic when compared to, say, vi.
Of course you can change key bindings with Emacs' 'define-key'
command. But as Emacs has so many keymaps, it is difficult to
redefine key bindings for all keymaps exhaustively. It is not what a
lazy man would do.
So I decided to use XKB. It is an extension of the X window system
that allows almost unlimited remapping of the keyboard layout. As key
events are changed by the X server, you do not have to redefine every
keymap with 'define-key'.
Here is the layout of my command keys.
I wanted to have two Control keys and two Meta keys at symmetrical
and handy positions. That's why they are there. Then I gathered
frequently used one-stroke commands on the right hand side and
frequently used multiple-stroke commands on the left hand side. Here
are some explanations.
-
'C-f', 'C-b', 'C-n' and 'C-p' are placed to
the position analogous to vi. Obviously these four are the most
frequently used commands and it is reasonable to set them there.
-
'C-a' and 'C-e' are
something like 'super C-b' and 'super C-f'. So 'C-a is placed
right above 'C-b' and 'C-e' is placed right above 'C-f'.
-
Since 'C-p' and 'C-n'
are now available at the right hand's home position, we can use 'up-arrow' and 'down-arrow'
for other purposes. I swapped them with 'Page
Up' and 'Page Down' so that I can
scroll up and down not only the current window but also the other
window.
-
Furthermore I assigned 'Home' and 'End' to the shift positions of 'Page Up' and 'Page Down'
described above, because the function beginning-of-buffer is something
like 'super Page Up' and end-of-buffer is something like 'super Page
Down'. These assignments also make the access to
beginning-of-buffer-other-window and end-of-buffer-other-window' easy.
-
Needless to say about 'C-d'; one of the most
frequently used commands. It is accessible by the most quick finger,
i.e., the right index finger.
-
I seldom use the mouse for cut & paste. Instead, I use kills and
yanks ('C-k', 'C-w',
'C-y', 'M-w', 'M-y', etc.) that are all one-stroke commands. So
they are gathered together to the lower right corner.
-
'C-x' and 'M-x' are
often used but they always require subsequent key strokes. So 'x' is assigned to left index finger (left for
multiple strokes and index finger for convenience).
-
'C-s' and 'C-r' are
very convenient commands but they require a string to be searched. So
they are on the left hand side, too.
-
I replaced 'left-arrow' key with 'undo'. This is an exception because 'undo' is a
single stroke command. But the left-arrow keytop suggests something
like 'going back'. Don't you think so?
-
Lastly I separated 'Alt' from 'Meta' and made 'Super' and
'Hyper' also available.
OK, but how come the 'h' key is on the right
hand side, and the 'z' and 'o' keys are on the left hand side? For the answer,
see the next section.
Further modification with global-set-key
In addition to the remapping with XKB, I also put some
'global-set-key' commands in my ~/.emacs file
for convenience.
-
The two file finding commands 'find-file' and 'find-file-other-window'
are assigned to 'C-o' and 'M-o'. With 'C-', this
window; with 'M-', other window. They are
frequently used, but the original bindings, i.e. 'C-x
C-f' and 'C-x 4 C-f', are too long for
a lazy man like me. They both require a filename input, so thay are
multiple-stroke commands. That is why they are placed on the left
hand side. See the explanation of 'C-z' and
'M-z' below.
-
If we redefine 'C-o', where has the
'open-line' command gone? It is 'M-m'. Why?
Because 'new-line' (assigned to 'C-m') and
'open-line' work symmetrically; the former inserts a '\n' before point and the latter inserts a '\n' after point. So now we have:
| key |
function name |
effect |
| C-m |
new-line |
insert a \n before point |
| M-m |
open-line |
insert a \n after point |
Well designed, isn't it?
-
The two buffer switching commands 'switch-to-buffer' and
'switch-to-buffer-other-window' are assigned to 'C-z' and 'M-z'. With 'C-', this window; with 'M-',
other window. They are frequently use, but the original bindings,
i.e. 'C-x b' and 'C-x 4
b', are too long for me. They both require a buffer name, so
they are multiple-stroke commands. That is why they are placed on the
left hand side. See the explanation of 'C-o'
and 'M-o' above.
This setting eats up 'C-z' and 'M-z'. But once invoked, I rarely iconify Emacs.
And I have never used 'zap-to-char'. So I do not need 'C-z' nor 'M-z'.
-
'C-h' (other-window) and 'M-h' (delete-other-window) are window changing
commands. Here, 'C-' and 'M-' are not so much symmetrical compared to the
other pairs described above. Anyway they are frequently used and do
not require further input, so placed on the right hand side.
-
If 'C-h' is used for other purpose, then where
is 'help-command', originally assigned to 'C-h'? It is 'M-i'. I
selected 'i' for the mnemonics of
'information'.
-
As 'Page Up' and 'Page
Down' are now available, we can use 'C-v' and 'M-v' for other
purposes. Thus I assigned them '1-line scroll-up' and '1-line
scroll-down'. These are useful to fine tune the displayed area.
This is the end of level 1 keyboard customisation.
Last modified : 20 December 2006