https://github.com/gcentauri/xah-fly-keys-layer
Spacemacs configuration layer for the xah-fly-keys package
https://github.com/gcentauri/xah-fly-keys-layer
ergonomics keymap productivity spacemacs spacemacs-layer
Last synced: 8 days ago
JSON representation
Spacemacs configuration layer for the xah-fly-keys package
- Host: GitHub
- URL: https://github.com/gcentauri/xah-fly-keys-layer
- Owner: gcentauri
- License: gpl-3.0
- Created: 2018-12-02T15:23:43.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-11-24T15:32:54.000Z (over 5 years ago)
- Last Synced: 2025-03-29T23:16:06.609Z (3 months ago)
- Topics: ergonomics, keymap, productivity, spacemacs, spacemacs-layer
- Language: Emacs Lisp
- Homepage:
- Size: 68.4 KB
- Stars: 13
- Watchers: 3
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.org
- License: LICENSE
Awesome Lists containing this project
README
#+TITLE: xah-fly-keys layer
[[file:img/xah-logo.png]]
* Table of Contents :TOC_4_gh:noexport:
- [[#description][Description]]
- [[#features][Features:]]
- [[#install][Install]]
- [[#configuration][Configuration]]
- [[#keyboard-layout][Keyboard layout]]
- [[#cursor-appearance-for-command-and-insert-modes][Cursor appearance for command and insert modes]]
- [[#preferred-incremental-search-function][Preferred incremental search function]]
- [[#preferred-m-x-function][Preferred M-x function]]
- [[#swap-the-leader-keys][Swap the leader keys]]
- [[#key-bindings][Key bindings]]
- [[#command-mode][Command mode]]
- [[#leader-key-map][Leader Key Map]]
- [[#sub-keymaps][Sub keymaps]]* Description
This layer adds an alternative modal editing mode for Emacs.#+BEGIN_QUOTE
"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."
#+END_QUOTE[[http://ergoemacs.org/misc/ergoemacs_vi_mode.html][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!
** Features:
- 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 [[http://ergoemacs.org/emacs/command-frequency.html][observed frequency of use]].* Install
Clone this repository into =.emacs.d/private/xah-fly-keys=, or where ever you
keep your private layers:#+begin_src sh
git clone https://github.com/gcentauri/xah-fly-keys-layer.git ~/.emacs.d/private/xah-fly-keys
#+end_srcNote - 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 to
=SPC= interferes with the =which-key= mappings.
- set =dotspacemacs-colorize-cursor-according-to-state nil= so that the cursor
will reflect the =xah-fly-keys= state instead.** Configuration
*** Keyboard layout
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:
#+BEGIN_SRC elisp
(xah-fly-keys :variables xah-fly-keys-layout "dvorak")
#+END_SRC*** Cursor appearance for command and insert modes
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:#+begin_example
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
#+end_exampleFor example,
#+begin_src elisp
(xah-fly-keys :variables
xah-fly-keys-command-mode-cursor '("yellow" . box)
xah-fly-keys-insert-mode-cursor '("#ff00ff" . hbar))
#+end_srcIt defaults to very distinctive, contrasting cursors to help indicate state. :smile:
*** Preferred incremental search function
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.#+BEGIN_SRC elisp
(xah-fly-keys :variables xah-fly-keys-search-function 'helm-swoop)
#+END_SRC*** Preferred M-x function
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.#+BEGIN_SRC elisp
(xah-fly-keys :variables xah-fly-keys-M-x-function 'counsel-M-x)
#+END_SRC** Swap the leader keys
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.#+BEGIN_SRC elisp
(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)
#+END_SRCYou'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.* Key bindings
See [[http://ergoemacs.org/misc/ergoemacs_vi_mode.html][xah-fly-keys]] for the modal keymap defined by Xah Lee.
** Command mode
| 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 |
| ~~ | xah-previous-emacs-buffer |
| ~~ | xah-next-emacs-buffer |
| ~~ | xah-~previous-user-buffer |
| ~~ | xah-next-user-buffer |
| ~~ | xah-fly-command-mode-activate-no-hook |
| ~~ | xah-fly-leader-key-map |
| ~~ | xah-fly-command-mode-activate |
| ~~ | xah-fly-command-mode-activate |** Leader Key Map
| 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 |** Sub keymaps
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