xah fly keys Mode

, , …,

This is the home page of xah-fly-keys.el emacs keybinding mode.

“xah fly keys” is a modal editing mode, like vi, but the design of key/command choice is based on command frequency and ease-of-press key positions. The keymap is mostly the same as in ergoemacs-mode.

Currently, it is for Dvorak Keyboard Layout only. If you are not Dvorak user, you need to remap the keys to your layout.

Download

Download at https://github.com/xahlee/xah-fly-keys

Install

put the xah-fly-keys directory in ~/.emacs.d/lisp/

put the following in your emacs init at ~/.emacs.d/init.el

(add-to-list 'load-path "~/.emacs.d/lisp/xah-fly-keys/")
(require 'xah-fly-keys)

Key to Activate Command Mode

There is just 1 thing you need to config: choose a key for activating command mode.

By default, ↖ Home is for activating command mode. The command name is “xfk-command-mode-activate”.

Example:

;; make key 【home】 to activate command mode. (regardless what's current mode)
(global-set-key (kbd "<home>") 'xfk-command-mode-activate)

Put it in your emacs init.

This is useful, because different keyboard have different key positions. You want the key to be the most easy to press key. On a typical laptop keyboard, i recommend you set the Caps Lock key as the key to activate command mode.

I recommend you change the Caps Lock to type the ↖ Home key. Then, in emacs, set ↖ Home to activate xah fly mode, as is default.

Emacs cannot set Caps Lock directly. You need to use a keyboard tool. See:

Linux

Mac

Microsoft Windows

Key to Activate Inserting Mode

By default, Space activates insertion mode (while you are in command mode). The command name is “xfk-insert-mode-activate”.

You can set another extra key to absolutely switch to insertion mode, regardless what's current mode, like this:

;; make key 【end】 to activate insertion mode. (regardless what's current mode)
(global-set-key (kbd "<end>") 'xfk-insert-mode-activate)

Lead Key

in “xah fly keys”, practically all of emacs 【Ctrl+x 】 keybinding have a key that's a key sequence of the form 【▤ Menu key key】.

For example, ido-switch-buffer is 【▤ Menu c g】.

pc keyboard2
Typical PC keyboard. See the ▤ Menu key besides the right Ctrl.

This key is critical. Because it is used for vast majority of emacs commands.

You want this lead key to be something most easy to type. I recommend it to be something under the thumb. For example, left Alt.

I recommend to get a good symmetric keyboard with big thumb keys. See: Best Keyboard for Emacs

Configuration

The mode is really simple. Just open the file xah-fly-keys.el. There are only ≈100 lines of code, each line corresponds to a key.

The only difficulty is that you need to change muscle memory to adopt to this keyset. It'll be difficult, takes about 1 month to be fluent.

Truly Ergonomic Keyboard Configuration

xah-fly-keys is designed for any keyboard, including standard PC keyboard or fancy ones like

I use it on Truly Ergonomic Keyboard. Here's my current Truly Ergonomic Keyboard configuration.

xah truly ergonomic keyboard 207 config 2013-10-01
xah Truly Ergonomic Keyboard config

note the ↖ Home and ↘ End keys. They are used to switch between command/insertion modes.

Also note the F13F17 keys. They are used as single key or key sequence starting-keys. Majority are used in emacs, others are system-wide, mostly for controlling windows & tabs.

the “Apps” on the left space bar position means the ▤ Menu key. It is used as lead key for key sequences. Key sequence is used for non-fast-repeat commands, which is about all of emacs thousand commands, minus about 30 fast-repeat commands. 〔➤ Emacs: Fast-repeat vs Non-fast-repeat Commands & Keys

you can see the ▤ Menu key map at https://github.com/xahlee/xah_emacs_init/blob/master/xah_emacs_keybinding.el

Setting Up Keys on Mac

On Mac OS X, you can set up the right ⌘ Cmd key or right ⌥ Opt to be ▤ Menu key. You can also set the Caps Lock to be ↖ Home. See: Mac OS X: Keyboard Layout, Keymapping, Keybinding, Software ⌨

Why I Created It

here's some detail about why i created it.

i'm a QWERTY typer since ≈1987. Switched to Dvorak in ≈1993. Started to use emacs in 1997, live in it by 1998. Used default GNU keybinding up to 2006. Started to experience minor RSI discomfort a few times since 2010. 〔➤ Summary of My Typing & RSI Experience 1992 〜 2013

i always regarded the vi modal ways a hack of the hack of the unix lineage. 〔➤ History of Emacs & vi Keys〕 I'll never touch it. But starting in 2010, i had lots thoughts about keyboard efficiency, and it occurred to me the modal way is actually more efficient, for programers.

the reason is, that on average, ≈50% of key-strokes of programers are actually not data-entry (that is, 50% are actually moving cursor, copy/cut/delete text, etc.) 〔➤ Emacs's Command Frequency Statistics〕 That means, if using modal ways, 50% of the time you don't have to press key combinations to execute commands, just a single key for each command. So, the 50% of time when you call commands, each command you save about 1 or 2 key-stroke, so in total you save about 50% × 50% = 25% of key-strokes. The trade-off is that you have to constantly switch modes, which means adding a key stroke every time you do so. Overall, i estimate it saves you in the ball-park of 10% to 20% of key strokes.

i've been wanting to create and experiment with vi modal ways since 2010. While there's viper-mode (which is a vi-emulator) and there's evil-mode (which is based on vim (a more advanced vi)), but their key/command choices is largely historical, not a clean design based on efficiency.

see also: on vi Keybinding vs Emacs Keybinding

ergoemacs-mode Has Modal Feature Too

this ergoemacs-vi mode works well when used with ergoemacs-mode together.

Note that in ergoemacs-mode, it also has a modal way by itself. Check its documentation.

Like it?
Buy Xah Emacs Tutorial
or share
blog comments powered by Disqus