This layer adds an alternative 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.”
xah-fly-keys has been developed over years of experience by Xah Lee, a long time contributer to the Emacs community.
Gain the modal superpowers of the dark side, without succumbing to evil!
- You NEVER need to press 【Ctrl+x】or Meta! Use a leader key instead!
- There are about 200 commands with leader key sequences.
- Efficient keys for common navigation and editing tasks in command mode.
- The key bindings are based on experience and observed frequency of use.
Clone this repository into .emacs.d/private/xah-fly-keys
, or where ever you
keep your private layers:
git clone https://github.com/gcentauri/xah-fly-keys-layer.git ~/.emacs.d/private/xah-fly-keys
Note - the directory the layer files are in must be named xah-fly-keys
.
To use this configuration layer, add it to your ~/.spacemacs
. You will need to
add xah-fly-keys
to the existing dotspacemacs-configuration-layers
list in
this file. You should have the dotspacemacs-editing-style
set to 'emacs
.
It is recommended to change some of the defaults in your .spacemacs
file, in
order to avoid some unwanted cross-over with some key bindings.
- set the
dotspacemacs-leader-key
to an empty string, as having it set toSPC
interferes with thewhich-key
mappings. - set
dotspacemacs-colorize-cursor-according-to-state nil
so that the cursor will reflect thexah-fly-keys
state instead.
This layer assumes a qwerty
layout and uses that by default. You can configure
xah-fly-keys to use other keyboard layouts with the xah-fly-keys-layout
variable.
The possible values are:
azerty
,azerty-be
colemak
,colemak-mod-dh
dvorak
,programer-dvorak
qwerty
,qwerty-abnt
qwertz
workman
For example, to use the dvorak
layout, add the following to your layers list:
(xah-fly-keys :variables xah-fly-keys-layout "dvorak")
You can customize the appearance of the cursor using two variables:
xah-fly-keys-command-mode-cursor
xah-fly-keys-insert-mode-cursor
Both variables are a pair of the form (COLOR . CURSOR-TYPE)
. COLOR
is a string,
either one of the defined color words in the list-colors-display
or a hex
code for the color. The CURSOR-TYPE
is one of the types that can be set on
the cursor-type
variable:
t use the cursor specified for the frame nil don’t display a cursor box display a filled box cursor hollow display a hollow box cursor bar display a vertical bar cursor with default width (bar . WIDTH) display a vertical bar cursor with width WIDTH hbar display a horizontal bar cursor with default height (hbar . HEIGHT) display a horizontal bar cursor with height HEIGHT ANYTHING ELSE display a hollow box cursor
For example,
(xah-fly-keys :variables
xah-fly-keys-command-mode-cursor '("yellow" . box)
xah-fly-keys-insert-mode-cursor '("#ff00ff" . hbar))
It defaults to very distinctive, contrasting cursors to help indicate state. 😄
This will default to either helm-swoop
or swiper
if helm/ivy layer is used.
Otherwise it will be isearch-foward
. You can set it to your preferred command.
(xah-fly-keys :variables xah-fly-keys-search-function 'helm-swoop)
This defaults to the standard execute-extended-command
, which seems to be
remapped by helm or ivy if those layers are installed. Set this variable if
you prefer another M-x
command or need to configure it explicitly.
(xah-fly-keys :variables xah-fly-keys-M-x-function 'counsel-M-x)
If you’d like to have the Spacemacs leader key on the space bar rather than the xah-fly-keys menu, then it’s possible to swap them.
I tried implementing this with a config variable, but it doesn’t quite work as expected.
Until that is sorted out, add this to your dotspacemacs/user-config
to swap the leader
keys for Spacemacs and xah-fly-keys.
(defun xah-fly-keys-swap-spacemacs-leader ()
(progn
(define-key xah-fly-key-map (kbd "SPC") 'spacemacs-cmds)
(define-key xah-fly-key-map (kbd "M-m") 'xah-fly-leader-key-map)))
(add-hook 'xah-fly-command-mode-activate-hook 'xah-fly-keys-swap-spacemacs-leader)
You’ll also need to set the dotspacemacs-emacs-leader
key to an empty string.
It appears that sometimes the which-key
menu will be affected by this change.
See xah-fly-keys for the modal keymap defined by Xah Lee.
Key binding | Description |
---|---|
M-m | spacemacs commands keymap |
ESC | xah-fly-leader-key-map |
SPC | xah-fly-leader-key-map |
' | xah-cycle-hyphen-underscore-space |
, | xah-next-window-or-frame |
- | xah-backward-punct |
. | xah-forward-right-bracket |
/ | xah-goto-matching-bracket |
0 | xah-pop-local-mark-ring |
1 | xah-extend-selection |
2 | xah-select-line |
3 | delete-other-windows |
4 | split-window-below |
5 | delete-char |
6 | xah-select-block |
7 | xah-select-line |
8 | xah-extend-selection |
9 | xah-select-text-in-quote |
; | xah-end-of-line-or-block |
= | xah-forward-punct |
[ | hippie-expand |
` | other-frame |
a | smex |
b | xah-toggle-letter-case |
c | xah-copy-line-or-region |
d | xah-delete-backward-char-or-bracket-text |
e | backward-kill-word |
f | xah-fly-insert-mode-activate |
g | xah-delete-current-text-block |
h | xah-beginning-of-line-or-block |
i | previous-line |
j | backward-char |
k | next-line |
l | forward-char |
m | xah-backward-left-bracket |
n | isearch-forward |
o | forward-word |
p | xah-insert–space-before |
q | xah-reformat-lines |
r | xah-kill-word |
s | open-line |
t | set-mark-command |
u | backward-word |
v | xah-paste-or-paste-previous |
w | xah-shrink-whitespaces |
x | xah-cut-line-or-region |
y | undo |
z | xah-comment-dwim |
DEL | xah-fly-leader-key-map |
<C-f11> | xah-previous-emacs-buffer |
<C-f12> | xah-next-emacs-buffer |
<f11> | xah-~previous-user-buffer |
<f12> | xah-next-user-buffer |
<f8> | xah-fly-command-mode-activate-no-hook |
<f9> | xah-fly-leader-key-map |
<home> | xah-fly-command-mode-activate |
<menu> | xah-fly-command-mode-activate |
Key Binding | Description |
---|---|
SPC TAB | xah-fly–tab-key-map |
SPC RET | execute-extended-command |
SPC SPC | xah-fly-insert-mode-activate |
SPC ' | xah-show-form-feed-as-line |
SPC , | xah-fly-w-keymap |
SPC 3 | delete-window |
SPC 4 | split-window-right |
SPC 5 | balance-windows |
SPC 6 | xah-upcase-sentence |
SPC 9 | ispell-word |
SPC ; | save-buffer |
SPC \ | toggle-input-method |
SPC a | mark-whole-buffer |
SPC b | xah-toggle-previous-letter-case |
SPC c | xah-copy-all-or-region |
SPC d | xah-fly-e-keymap |
SPC e | xah-fly-dot-keymap |
SPC f | switch-to-buffer |
SPC g | kill-line |
SPC h | beginning-of-buffer |
SPC i | xah-fly-c-keymap |
SPC j | xah-fly-h-keymap |
SPC k | xah-fly-t-keymap |
SPC l | xah-fly-n-keymap |
SPC m | dired-jump |
SPC n | end-of-buffer |
SPC o | xah-fly-r-keymap |
SPC p | recenter-top-bottom |
SPC q | xah-fill-or-unfill |
SPC r | query-replace |
SPC s | exchange-point-and-mark |
SPC t | xah-show-kill-ring |
SPC u | isearch-forward |
SPC v | xah-paste-or-paste-previous |
SPC w | xah-fly-comma-keymap |
SPC x | xah-cut-all-or-region |
SPC y | xah-search-current-word |
SPC DEL | xah-fly-insert-mode-activate |
You’ll notice that there are several sub keymaps after pressing a leader key.
These are organized by ease of use, and should really be categorized by
finger and keyboard row. I’ve listed some of the functionality for each of the
keymaps, but use which-key
and you’ll discover more details.
- 【SPC ,】 - Eval, kill emacs
- 【SPC k】 - registers, replace, occur
- 【SPC o】 - rectangles, macros, number registers
- 【SPC l】 - modes, view, windows
- 【SPC j】 - help, apropos, info
- 【SPC d】 - inserting chars, brackets, unicode
- 【SPC i】 - files, bookmarks, external apps
- 【SPC w】 - xref, find identifiers
- 【SPC e】 - search, highlight, fonts
- 【SPC TAB】 - indent, expand, abbrev