Emacs: Xah Fly Keys Tutorial

By Xah Lee. Date: . Last updated: .

Here's Xah Fly Keys tutorial for beginners. I assume you have made no customization.

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 other-frame unsplit split Select¶ S Line S w S (▮) M-x ⌫() insert ⌦|¶ ←|¶ →|¶ ⌦w format ⌫␣ ⌫w mark undo →w ←w Case search paste cut copy cmt ←( →) →() next◫ leader key Cmd Mode

Command/Insert Mode Switch

Alt+Space (xah-fly-command-mode-activate) → switch to command mode.

f or Space Space (xah-fly-insert-mode-activate) → switch to insert mode.

Cursor Movement

Switch to command mode. Then, follow keys are arrows.

    i
 j k l

Try them. Try many times. Feel your finger muscles with the cursor movement.

Space h (beginning-of-buffer)

Space n (end-of-buffer)

Text Editing

d (xah-smart-delete) → Delete something to the left. It may be 1 char, or whitespace, or bracketed text.

g (xah-delete-current-text-block) → Delete the current text block.

5 (delete-char) → Delete 1 character to the right.

w (xah-shrink-whitespaces) → Delete whitespaces. Repeated call delete more whitespaces.

Space g (kill-line) → Delete to end of line.

undo

y (undo) → undo.

To redo, do an undo, then press key to switch to command mode (or Ctrl+g), then do undo. To reverse direction, press Ctrl+g again.

Tip: I recommend not to use any external undo/redo package.

Cut Copy Paste

x (xah-cut-line-or-region) → Cut current line or selection. Repeated call cut more lines.

c (xah-copy-line-or-region) → Copy current line or selection. Repeated call copy more lines.

v (xah-paste-or-paste-previous) → Paste. Repeated call paste previous.

To paste something twice, call paste, then enter space or return or switch command mode, then paste again.

To paste something 5 times, Space . (universal-argument) 5, then call paste.

More:

Space c (xah-copy-all-or-region) → Copy all.

Space x (xah-cut-all-or-region) → Cut all.

Space t (xah-show-kill-ring) → Show copy history.

Copy and Paste to Register

[see Emacs: Copy to Register]

Mark and Text Selection

t (set-mark-command) → Start selection. Move cursor to expand. Press again to unmark.

Text Selection Shortcuts

6 (xah-select-block) → Selects text block. Repeated call extends to next block.

7 (xah-select-line) → Selects line. Repeated call extends to next line.

8 (xah-extend-selection) → Select current word or bracketed text. Repeated call extend selection.

9 (xah-select-text-in-quote) → selects inner text between brackets or quotes (e.g. string)

Space a (mark-whole-buffer) → select all.

execute-extended-command (M-x)

a or Space Enter (execute-extended-command) → call a command by name.

iSearch

n (isearch-forward) → Interactive search and also move cursor.

Space y (xah-search-current-word) → Search current word or selection.

When in isearch:

There's no key to begin backward search. Just do isearch then press left arrow key.

Tip: i recommend not installing external packages to jump cursor to locations.

Find Replace

Space r (query-replace)

Space k r (query-replace-regexp)

Open Close Save

You can use the following standard keys for now.

When you are comfortable with Xah Fly Keys, and feel like you want to reduce using Control key, then learn the following.

Open Files

Space i e (find-file) → Open file.

Space i f (xah-open-file-at-cursor) → Open URL or file path.

Space i c (xah-copy-file-path)

Space m (dired-jump) → go to dired and place cursor on file name.

Open recently opened/closed files:

Bookmark related for fast open files:

You should never need to type file path to open file, unless it's a new file you rarely work with.

All files or directories you work daily, should be bookmarked [see Emacs: Bookmark] , or with open recent. [see Emacs: Open Recently Opened File]

Open Files in External App

switch buffer

Split Buffer

3 (delete-other-windows) → Unsplit all.

4 (split-window-below) → Split top/bottom

, (xah-next-window-or-frame) → Switch cursor to next pane or next window (emacs frame).

Space 3 (delete-window) → remove current pane.

Space 4 (split-window-right) → split left/right.

Tip: on large monitor, avoid workflow with 1 fullscreen. [see Emacs Workflow: Fullscreen vs Multiple Frames]

Working with Quote and Brackets

xah-fly-keys has a system to work with brackets. Brackets includes ()[]{}“” and all Unicode: Brackets, Quotes «»「」【】《》

Move to Brackets

Select Brackets

when cursor is on a bracket, 8 (xah-extend-selection) selects the whole.

Delete Whole Bracketed Text

d (xah-smart-delete) → when the left char is a bracket, delete the bracketed text. The deleted text is automatically copied.

Delete Bracket Pair

move cursor to the right of a bracket, then Space . (universal-argument) d (xah-smart-delete)

Delete a Single Bracket

move cursor to the left of it, then press 5 (delete-char) .

Insert Brackets

Now, type Space d Ctrl+h to see all other brackets and quotes you can insert.

Change Brackets

Font Size

List All Leader Keys

Space Ctrl+h → list all leader key sequences and commands. (if you have which-key-mode installed, you must turn it off first.)

More Advanced

ok, the above are the basics.

Now, there are about 200 commands with leader keys. These basically replace what emacs C-x does.

You might want to learn them as you go.

When in command mode, press Space Ctrl+h to list all leader key sequence commands.

Remember to use Alt+x describe-function and Alt+x describe-key to find what's the key or command name.

Misc Notes

Command Mode Key Must be Most Easy Key

It's critically important that the key to switch to command mode must be the most easy key on your keyboard.

I suggest the CapsLock on typical PC keyboards or laptop keyboards.

For how, see Emacs: Xah Fly Keys Customization

Insert Mode is Same as Default GNU Emacs Key

When in insert mode, it acts like Xah Fly Keys is off. (except a handful of global keys with Ctrl or Meta, but you can turn them off in customization.)

In some emacs modes such as dired , typing a letter will run some special command. For example, in dired, m for mark, u for unmark.

So, whenever you think there is some problem, do switch to insert mode.