Emacs: Xah Fly Keys
2018-10-09 new. subreddit discussion forum. https://www.reddit.com/r/xahflykeys/
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.
Video Intro
If you like to watch a video intro, here it is.
Download
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 ;; possible layout values: ;; "qwerty" ;; "qwerty-abnt" ;; "qwertz" ;; "dvorak" ;; "programer-dvorak" ;; "colemak" ;; "colemak-mod-dh" ;; "workman" ;; 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 ;; possible layout values: ;; "qwerty" ;; "qwerty-abnt" ;; "qwertz" ;; "dvorak" ;; "programer-dvorak" ;; "colemak" ;; "colemak-mod-dh" ;; "workman" ;; dvorak is the default (xah-fly-keys 1)
What Does Command Mode Do?
When in command mode:
- Right hand letter keys are moving cursor, in general. For example, i j k l , are arrows.
- Left hand letter keys are deleting/modifying text.
Key to Activate Command Mode
The command to activate command mode is
Alt+x xah-fly-command-mode-activate
and
Alt+x xah-fly-command-mode-activate-no-hook.
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
- When in command mode, the cursor shape is a black rectangle ▮ (won't work in some text terminal).
- When in command mode, the first character in emacs status bar (aka mode line) displays capital C.
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
- When in insert mode, the cursor shape is a i-beam ⌶. (won't work in some text terminal)
- When in insert mode, the first character in emacs status bar (aka mode line) displays capital I.
Leader Key for Commands
You NEVER need to press 【Ctrl+x】.
For example,
- 【Ctrl+x b】 (
switch-to-buffer) is 【Space f】 - 【Ctrl+x Ctrl+f】 (
find-file) is 【Space i e】 - 【Ctrl+x 1】 (
delete-other-windows) is 3 while in command mode.
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.
Globally, the leader key is the F9 key.
For example, 【F9 f】
is
switch-to-buffer. No need to switch to command mode first.
Here's example of frequently used ones.
- 【Space Space】 →
xah-fly-insert-mode-activate - 【Space Enter】 →
execute-extended-command - 【Space f】 →
switch-to-buffer - 【Space a】 →
mark-whole-buffer(select all) - 【Space h】 →
beginning-of-buffer - 【Space n】 →
end-of-buffer - 【Space r】 →
query-replace - 【Space k r】 →
query-replace-regexp
- There are about 200 commands with leader key sequence.
- Most frequently used commands have 2-key sequence (counting the leader key.)
- Other commands have 3-key sequence. 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.
Emac's M-x
When in command mode:
- 【a】 →
execute-extended-command. - 【Space Return】 →
execute-extended-command.
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:
- 【Alt+f】 (
forward-word) is 【o】 while in command mode. - 【Alt+%】 (
query-replace) is 【Space r】 while in command mode.
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)
- 【Ctrl+Tab】 →
xah-next-user-buffer - 【Ctrl+Shift+Tab】 →
xah-previous-user-buffer - 【Ctrl+v】 → Paste.
yank - 【Ctrl+w】 →
xah-close-current-buffer - 【Ctrl+z】 →
undo - 【Ctrl+n】 →
xah-new-empty-buffer - 【Ctrl+o】 → open.
find-file - 【Ctrl+s】 →
save-buffer - 【Ctrl+Shift+s】 → Save As.
write-file - 【Ctrl+Shift+t】 →
xah-open-last-closed - 【Ctrl++】 → zoom-in.
text-scale-increase - 【Ctrl+-】 → zoom-out.
text-scale-decrease
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:
- 【Ctrl+c】 for major mode commands.
- 【Ctrl+g】 for cancel.
- 【Ctrl+q】 for
quoted-insert. - 【Ctrl+h】 for help.
isearch
When in command mode, 【n】 starts isearch-forward.
When in isearch:
- left/right arrow keys ← → do search backward/forward.
- up/down arrow keys ↑ ↓ do previous/next search item.
- Return exits isearch and leave cursor at the current location.
- Ctrl+g exits isearch and leave cursor at original location.
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
Customization
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. (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 highly recommend ergoemacs-mode.
https://ergoemacs.github.io/ (ergoemacs-mode is lead by Matthew Fidler.)
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?
YES
xah-fly-keys chat Forum
https://www.reddit.com/r/xahflykeys/
created the subreddit on 2018-10-07. Post your questions, answers, experiences, wishlist, comparisions, criticisms, or your blogs about it there.
Why I Created It
See Emacs: Xah Fly Keys History
see also: on vi Keybinding vs Emacs Keybinding
Xah-Fly-Keys Testimonial
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
Then I found xah-fly-keys. This is a modal set of keybindings for Emacs, that is, the keybindings consist of pressing keys in succession rather than holding down modifier keys. It's quite good, quite good.
… I'm pretty settled on xah-fly-keys now, …
[Writing to think 2: Write harder, the editor caper By Jaredj. At http://j.agrue.info/the-editor-caper.html ]
[Writing to think 2: Write harder, the keyboard caper By Jaredj. At http://j.agrue.info/the-keyboard-caper.html ]
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)
Emacs Pinky
- Best Keyboard for Emacs
- Why Emacs Keys are Painful
- How to Avoid Emacs Pinky
- Emacs Command Frequency Statistics
- Swap CapsLock and Control
- Famous Programers with RSI
- My Typing/RSI Experience 1992 to 2017
- Hand Health: vi Esc Key Syndrome
- Emacs, RSI, My Experiences
- Using Voice to Code Faster than Keyboard 📺
- ergoemacs mode
- Xah Fly Keys
If you have a question, put $5 at patreon and message me.