Emacs: Xah Fly Keys Tutorial
Here's Xah Fly Keys tutorial for beginners. I assume you have made no customization.
Chose a layout
All keybinding shortcuts on this page changes accordingly.
Activate command mode
- Esc (
xah-fly-command-mode-activate)
or any of
- Alt+Space
- Ctrl+Space
Activate insert mode
- f or Space Space (
xah-fly-insert-mode-activate)
Exit emacs
- Space , x (
save-buffers-kill-terminal)
Cursor movement
Move by char
Try them. Try many times. Feel your finger muscles with the cursor movement.
Move by word
- u (
backward-word) - o (
forward-word)
Move by paragraph
- h (
xah-beginning-of-line-or-block) - ; (
xah-end-of-line-or-block)
Repeated call moves by paragraph.
Move to beginning of buffer
- Space h (
beginning-of-buffer) - Space n (
end-of-buffer)
Delete text
- e (
backward-kill-word) - r (
kill-word)
- d (
xah-smart-delete) → Cut something to the left. If left is whitespaces, cut them all. If it is any bracket, cut the brackets and its innertext. Else, delete 1 char.
- w (
xah-shrink-whitespaces)
- Space
g
. (
kill-line) - Space g h (
xah-delete-current-text-block)
Undo
- y (
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) → Repeated call cut more lines. - c (
xah-copy-line-or-region) → Repeated call copy more lines. - v (
xah-paste-or-paste-previous) → 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.
Cut All, Copy All
- Space x (
xah-cut-all-or-region) - Space c (
xah-copy-all-or-region)
Mark and text selection
- g (
xah-extend-selection) → Start selection. By default, select current word, or bracketed text, or whitespaces, or other, depending on what's under cursor. Move cursor to expand.
- t (
set-mark-command) → start selection but don't select anything.
- Space
g
g (
exchange-point-and-mark)
- Space g k (
xah-select-text-in-quote)
Select All
- Space a (
mark-whole-buffer) → Select all.
Call command by name (m-x)
- a (
execute-extended-command) - Space Return (
execute-extended-command)
Search text
- n (
isearch-forward) → Start isearch - Space y (
xah-search-current-word) → Search current word or selection.
When in isearch:
- Ctrl+y → paste.
- ← → → search backward/forward.
- ↑ ↓ → previous/next search history.
- Return → exit isearch and leave cursor at the current location.
- Ctrl+g exit isearch and leave cursor at original location.
🟢 tip: i recommend not installing external packages to jump cursor to locations.
Find replace
- Space r (
query-replace) - Space k r (
query-replace-regexp)
New open close save
You can use the following standard keys.
- Ctrl+n (
xah-new-empty-buffer) - Ctrl+o (
find-file) → Open. - Ctrl+w (
xah-close-current-buffer) - Ctrl+s (
save-buffer) - Ctrl+Shift+s (
write-file) → Save as. - Ctrl+Shift+t (
xah-open-last-closed) → Open last closed
When you are comfortable with Xah Fly Keys, and do not want to use Control key, then use the following.
- Space i l (
xah-new-empty-buffer) - Space i e (
find-file) - Space u (
xah-close-current-buffer) - Space ; (
save-buffer) - Space i ; (
write-file) - Space i r (
xah-open-last-closed)
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 File, Recently Closed File
Emacs: Open Recently Opened File
- Space i j (
recentf-open-files) → List recently opened files. - Space i r (
xah-open-last-closed) - Space i y (
xah-open-recently-closed) → List recently closed files.
Bookmark
- Space i p (
bookmark-set) → Add current file to bookmark. - Space i i (
bookmark-bmenu-list) → List bookmarks - Space i o (
bookmark-jump) → Open a file in bookmark.
Switch buffer
- Space f (
switch-to-buffer) - Space i d (
ibuffer) → List buffers.
-
Ctrl+8 or Ctrl+Tab (
xah-next-user-buffer) -
Ctrl+7
or
Ctrl+Shift+Tab (
xah-previous-user-buffer)
Split window
- - (
split-window-below) → Split to bottom. - = (
split-window-right) → Split to right. - ' (
delete-other-windows) → Unsplit all.
Switch Window
- , (
xah-next-window-or-frame) → Switch cursor to next pane or next window (emacs frame).
Working with quote and brackets
xah-fly-keys has a system to work with brackets.
Brackets includes
()[]{}“”
and all
Unicode: Brackets 「」【】《》
Move to Brackets
- m (
xah-backward-left-bracket) → Move to left bracket. - . (
xah-forward-right-bracket) → Move to right bracket. - / (
xah-goto-matching-bracket) → When cursor is on a bracket, jump to the matching one. If cursor is not on a bracket, move it to parent left bracket.
Select Bracket Text
when cursor is on a bracket,
H (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 right of it, then press E.
Change Brackets
- Space r h (
xah-change-bracket-pairs)
Font size
- Ctrl+= (
text-scale-increase) - Ctrl+- (
text-scale-decrease)
- Space l a (
text-scale-adjust)
List all leader keys
More advanced
- Space
g
c (
xah-show-kill-ring) → Show copy history
Running Program
- Space
.
c
(
xah-run-current-file) - Space
.
d
(
xah-delete-current-file-make-backup)
More Leader Keys
There are about 200 commands with leader key prefix. They basically replace what emacs C-x does.
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.