Emacs: Xah Fly Keys

By Xah Lee. Date: . Last updated: .

What's New

2021-02-21 now supports pt-nativo layout (for Portuguese). Thanks to xavierpinho. [see Ergonomic Keyboard Layout for Portuguese: pt-Nativo]

2021-02-09 now supports ergo layouts for germany: neo2, koy, adnw. Thanks to VitruvianVice.

2020-07-12 the old version of xah fly keys before the key engine change on 2020-04-27 is now at xah-fly-keys_old_2020-04-18.el

2020-04-27 Major engine rewrite, by Dan Langlois and Will Dey (wi11dey). Big thank you. Now, xah fly keys has priority, won't have the very annoying problem in modes like magit and org. In next few days am going to update the customization page. Vast majority of code will work as is. If you have problem, goto xahlee discord, or file a bug report.

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, 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, from a friend

Video Intro

If you like to watch a video intro, here it is.

intro to xah fly keys


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

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

MELPA Install

[see Emacs: Install Package with ELPA/MELPA]

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

(require 'xah-fly-keys)

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

;; possible layout values: azerty, azerty-be, colemak, colemak-mod-dh, dvorak, programer-dvorak, qwerty, qwerty-abnt, qwerty-no (qwerty Norwegian), qwertz, workman, norman, neo2, koy, adnw

(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

;; possible layout values: azerty, azerty-be, colemak, colemak-mod-dh, dvorak, programer-dvorak, qwerty, qwerty-abnt, qwerty-no (qwerty Norwegian), qwertz, workman, norman, neo2, koy, adnw

(xah-fly-keys 1)

What Does Command Mode Do?

1 2 3 4 5 6 7 8 9 0 a b c d e f g h i j k l m n o p q r s t u v w x y z , . ' \ / = - [ ] ; ` Xah Fly Keys command mode layout M-x isearch ⇤↖ ⇥↘ insert undo ←word →word ␣insert ⌦¶ mark ⌦w ⌫w ⌦␣⌫ reformat Case paste cut copy cmt ←( →) goto() next window split unsplit select ¶ leader key Cmd Mode S Line S word S quote

When in command mode:

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 besides right Ctrl)

Command Mode Visual Indicator

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

Insert Mode

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.)

Key to Activate Insert Mode

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

When in command mode, f activates insertion mode.

When in command mode, Space Space also activates insertion mode.

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.

For example,

The first key in a key sequence we call it the “leader key”. For example, the Space is the leader key in Space f.

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

Here's example of frequently used ones.

There are about 200 commands with leader key sequence. Most frequently used commands have 2 keys Other commands have 3 keys. Some rarely used have 4.

Use Which-Key-mode to Help Learn Leader 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

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.)

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 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.


Emacs: Xah Fly Keys Tutorial


Emacs: Xah Fly Keys Customization

Batman Keyboards

xah-fly-keys is designed for any keyboard. I made 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.

Here's suggested optimal configuration.

Kinesis keyboard layout d14 2020-03-20 b3nqt
Kinesis/Ergodox layout for xah-fly-keys

uhk xah-fly-keys dvorak 2020-01-06 h6zrz-s388x161
xah-fly-keys with Ultimate Hacking Keyboard

truly ergonomic keyboard xah fly keys layout 55098 numlock layer-s334x187
xah-fly-keys with Truly Ergonomic Keyboard
gergo xah fly keys layout L0 2020-06-27 sjfb2
Gergo Keyboard, xah fly keys layout at Xah Gergo Layout

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 is part of FSF GNU Emacs, in ELPA repository. (but you should probably download the version from MELPA, because it's usually more up-to-date.)

If you don't like modal ways, I 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.

If you practice 2 hours per day, probably about a month to be fluent.

Does xah-fly-keys work in terminal?


Chat Forum


Emacs: Xah Fly Keys History

See also: on vi Keybinding vs Emacs Keybinding


Xah Fly Keys Testimonial

Emacs Tutorial

Emacs Init

Emacs Keys


ELisp Examples

ELisp Write Major Mode

Emacs Keys


Keybinding How-To

Key Tips

Emacs Pinky

Keybinding Design