Emacs: Xah Fly Keys

By Xah Lee. Date: . Last updated: .

2018-04-25 NEW! now supports Colemak Mod-DH layout (and Colemak). Thanks to Henkjan Gersen.

xah-fly-keys is more efficient than vim, or any keybinding set in history.

xah-fly-keys.el is a modal editing mode for emacs, like vi, but the design of key/command choice is based on command frequency statistics and ease-of-key score. Most frequently used commands have most easy keys.

If you have hand pain from using emacs, you should consider using xah-fly-keys. Never need to press Ctrl+x and never need to press Meta anymore.

xah fly keys kinesis 2017 09 60363
Xah Fly Keys and Kinesis keyboard


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

Also on MELPA http://melpa.org/#/xah-fly-keys

MELPA Install

[see Emacs: How to Install Packages Using ELPA, MELPA]

After you installed from MELPA, put the following in your init:

(require 'xah-fly-keys)

(xah-fly-keys-set-layout "qwerty") ; required if you use qwerty

;; for other layout, use one of
;; "workman"
;; "qwertz"
;; "programer-dvorak"
;; "dvorak"
;; "colemak"
;; "colemak-mod-dh"
;; dvorak is the default

(xah-fly-keys 1)

Manual Install

Put the file xah-fly-keys.el in ~/.emacs.d/lisp/

Put the following in your emacs init:

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

(require 'xah-fly-keys)

(xah-fly-keys-set-layout "qwerty") ; required if you use qwerty

;; for other layout, use one of
;; "workman"
;; "qwertz"
;; "programer-dvorak"
;; "dvorak"
;; "colemak"
;; "colemak-mod-dh"
;; dvorak is the default

(xah-fly-keys 1)

Key to Activate Command Mode

The command to activate command mode is Alt+x xah-fly-command-mode-activate.

By default, it has the following keys:

Alt+Space】 or Home or 【F8】 or 【▤ Menu】 (the menu key is the key on Microsoft keyboards, usually the right side.)

Command Mode Visual Indicator

xah fly keys command mode 2018 01 30
xah-fly-keys in command mode

Want Does Command Mode Do

When in command mode:

xah fly keys layout qwerty.svg
xah-fly-keys command mode layout. 〔qwerty, svg file 721×272 〕 〔dvorak, svg file 721×272

Only 36 commands, but master these few will already beat the efficiency of vim.

To find the command name of a key, switch to command mode , then Alt+x describe-keyCtrl+h k】, then press the key. (try it now, as you will do this frequently when learning.)

Key to Activate Insert Mode

The command to activate insert mode is Alt+x xah-fly-insert-mode-activate.

When you are in command mode, 【f】 (Dvorak 【u】) activates insertion mode.

When you are in command mode, 【Space Space】 also activates insertion mode.

Want Does Insert Mode Do

When in insert mode, keys insert characters. (or, whatever a letter key does in the current major mode. For example, in dired, m marks a file.)

Insert Mode Visual Indicator

xah fly keys insert mode 2018 01 30
xah-fly-keys in insert mode

Leader Key for Commands

You NEVER need to press 【Ctrl+x】.

Any emacs command that has a keybinding starting with Ctrl+x, has also a key sequence binding in xah-fly-keys, or a single key while in command mode.

For example,

The first key in a key sequence we call it the “leader key”.

In the above examples, the Space is the leader key.

When in command mode, the Space is a leader key.

Globally, the leader key is the F9 key. For example, query-replace is 【Space r】 while in command mode, but 【F9 r】 always works. (in Dvorak, 【F9 p】)

There are about 200 commands with leader key sequence. When learning xah-fly-keys, i recommend using which-key at https://github.com/justbur/emacs-which-key

With which-key on, when you press a leader key, subsequent keys and commands are displayed.

emacs which key mode
emacs which-key-mode.

Here's the most frequently used leader key commands and their key sequence. The leader key is indicated by leader.

QWERTYDvorakcommand name
leader Spacesamexah-fly-insert-mode-activate
leader Entersameexecute-extended-command
QWERTYDvorakcommand name
leader fleader uswitch-to-buffer
leader aleader amark-whole-buffer (select all)
leader hleader dbeginning-of-buffer
leader nleader bend-of-buffer
leader rleader pquery-replace
leader k rleader t pquery-replace-regexp

Most frequently used commands have 2-key sequence (counting leader key.) Other commands have a 3-key sequence. A few commands have 4 keys sequence, but these are basically used once a month or never.

Emac's M-x

When in command mode:

NEVER Need to Press Meta

Any emacs command that has a Meta keybinding also have a keybinding without Meta in xah-fly-keys.

For example:

To find the key, Alt+x describe-key, then press the meta key combination. Emacs will print all its keybinding.

Standard Control Key Shortcuts

The following standard keys are supported by default. (they can be disabled. See Emacs: Xah Fly Keys Customization)

It is not necessary to use these key shortcuts. These commands all have keys that do not need Ctrl.

The only time you need to press Ctrl key are:


When in command mode, 【n】 (Dvorak 【b】) starts isearch-forward.

When in isearch:

Dired Mode, Org Mode, Single Keys

In plain GNU Emacs, in some modes, typing a letter key does not insert letter, but runs a special command. For example, in dired, 【m】 for mark, 【u】 for unmark.

With xah-fly-keys, when in insert mode, typing letter key will do whatever of that mode's commands.

Xah Fly Keys Tutorial

Emacs: Xah Fly Keys Tutorial


Emacs: Xah Fly Keys Customization

Batman Keyboards

xah-fly-keys is designed for any keyboard. Special care has taken to make sure it works well for • normal PC keyboards, • Apple Keyboards ⌨, • Laptop Keyboards, and works well in both text terminal or graphical user interface.

If you have a batman keyboard, much merrier.

Suggested optimal configuration: Kinesis/Ergodox layout for xah-fly-keys

Suggested optimal configuration: xah-fly-keys with Truly Ergonomic Keyboard

Frequently Asked Questions

How does it compare to ergoemacs-mode?

ergoemacs-mode remaps the most frequently used emacs commands to use 【Alt+key】, with key choice based on frequency of command call.

ergoemacs-mode also supports standard {Open 【Ctrl+o】, Close 【Ctrl+w】, New 【Ctrl+n】, …} keys familiar to everyone. People who never use emacs can use it right away, without knowing any emacs keys.

ergoemacs-mode supports over 10 keyboard layouts, including: {QWERTY, Dvorak, Colemak, German, French, …}.

ergoemacs-mode is flexible. It provides many key set “themes”. You can also design your own.

ergoemacs-mode is part of FSF GNU Emacs, in ELPA repository.

If you don't like modal ways, I highly recommend ergoemacs-mode.

https://ergoemacs.github.io/ (ergoemacs-mode is lead by Matthew Fidler.)

ergoemacs layout us
ergoemacs mode. Use Alt as the primary key for emacs commands.

How does it compare with evil-mode?

evil-mode lets you use vim keys in emacs. It has large number of users, and with the advantage that you'll be able to use both emacs and vim.


How long does it take to learn xah-fly-keys?

It'll take the same time when learning vi for the first time.

Probably about a month to be fluent.

Does xah-fly-keys work in terminal?


Why I Created It

See Emacs: Xah Fly Keys History

see also: on vi Keybinding vs Emacs Keybinding

Xah-Fly-Keys Testimonial

yay! “Hello! Been using your fly-keys for almost two weeks now and I find them super convenient and…” — Arkady. (2018-03)

Coincidentally, I started using Xah Fly Keys a week ago and found this tutorial / reference to be super useful - thanks! —Sean O'Reilly. (2018-03-31)

xah fly keys testimonial 2017 09 12 30453
xah fly keys testimonial 2017-09-12

Thanks for xah-fly-keys. I think I would never adhered to Emacs if it was not for that. It's one of that things that after knowing you can't live without it. — Alex O. 2017-11-08

Emacs Pinky Topic

  1. How to Avoid Emacs Pinky
  2. Why Emacs Keys are Painful
  3. Best Keyboard for Emacs
  4. Emacs: Xah Fly Keys
  5. Emacs's Command Frequency Statistics
  6. Emacs: Why You Should Not Swap CapsLock and Control
  7. Famous Programers with Repetitive Strain Injury
  8. My Typing/RSI Experience 1992 to 2017
  9. Programer Hand Health: vi Esc Key Syndrome
  10. Emacs, RSI, My Experiences
  11. Using Voice to Code Faster than Keyboard 📺
Patreon me $5 patreon

Or Buy Xah Emacs Tutorial

Or buy a nice keyboard: Best Keyboard for Emacs

If you have a question, put $5 at patreon and message me.