This repository has been archived on 2024-10-22. You can view files and clone it, but cannot push or open issues or pull requests.
spacemacs/layers/+intl/keyboard-layout/README.org

285 lines
10 KiB
Org Mode
Raw Normal View History

2016-04-04 20:35:01 +00:00
#+TITLE: keyboard-layout layer
2017-06-06 10:24:30 +00:00
[[file:img/keyboard-layout-layer-logo.png]]
2016-04-04 20:35:01 +00:00
* Table of Contents :TOC_4_gh:noexport:
2017-05-22 14:16:12 +00:00
- [[#description][Description]]
- [[#installation][Installation]]
- [[#configuration][Configuration]]
- [[#enabledisable-package-configurations][Enable/Disable package configurations]]
- [[#addoverride-key-bindings][Add/Override key bindings]]
- [[#concept][Concept]]
- [[#keyboard-layouts][Keyboard layouts]]
2017-06-06 10:24:30 +00:00
- [[#bepo][Bepo]]
- [[#dvorak][Dvorak]]
- [[#colemak][Colemak]]
- [[#workman][Workman]]
- [[#neo][Neo]]
2017-05-22 14:16:12 +00:00
- [[#package-configurations][Package Configurations]]
2017-06-06 10:24:30 +00:00
- [[#key-bindings][Key bindings]]
- [[#image-sources][Image sources]]
2016-04-04 20:35:01 +00:00
* Description
2017-06-06 10:24:30 +00:00
This layer configures some key bindings in Spacemacs, to make it compatible with
keyboard layouts that differs from the traditional =en-us= =QWERTY= layout.
2016-04-04 20:35:01 +00:00
* Installation
To use this configuration layer, add it to your =~/.spacemacs=. You will need to
add =keyboard-layout= to the existing =dotspacemacs-configuration-layers= list
in this file. You can then select the desired layout by specifying the
=kl-layout= variable:
2016-04-04 20:35:01 +00:00
#+begin_src emacs-lisp
(setq-default dotspacemacs-configuration-layers '(
(keyboard-layout :variables kl-layout 'dvorak)))
#+end_src
* Configuration
** Enable/Disable package configurations
2016-04-04 20:35:01 +00:00
This layer can be customized with two variables:
- kl-enabled-configurations
- kl-disabled-configurations
The first one is used to set the list of configurations to activate, and the
second one to prevent loading certain configurations. If the
2017-06-06 10:24:30 +00:00
=kl-enabled-configurations= variable is =nil=, (default: =nil=), then all
configurations are loaded. Otherwise, only the listed configurations are loaded.
Any configuration listed in =kl-disabled-configurations= will never be loaded,
whether it is in the enabled list or not (default: =nil=).
2016-04-04 20:35:01 +00:00
#+begin_src emacs-lisp
(setq-default dotspacemacs-configuration-layers '(
(keyboard-layout :variables
kl-layout 'dvorak
kl-disabled-configurations '(org magit))))
#+end_src
** Add/Override key bindings
2017-06-06 10:24:30 +00:00
It is possible to override or add key bindings, by defining functions named
=kl/pre-config-<NAME>= and =kl/post-config-<NAME>= in =dotspacemacs/user-init=.
2017-06-06 10:24:30 +00:00
They are called just before and after the actual configuration of the key
bindings in this layer. *You don't have to think about when to apply the
2016-04-04 20:35:01 +00:00
configuration by yourself*. =<NAME>= is the name of the configuration you want
2016-08-03 13:18:45 +00:00
to customize, they are listed under the [[#configuration][Configuration]] section.
2016-04-04 20:35:01 +00:00
Example:
#+begin_src emacs-lisp
(defun kl/post-config-company ()
"Company delete backward."
(kl/set-in-state company-active-map (kbd "C-w") 'evil-delete-backward-word))
#+end_src
2017-06-06 10:24:30 +00:00
Note: If you define some of these functions in your own layer, then make sure
that the =keyboard-layout= layer is placed *after* it in the
2016-04-04 20:35:01 +00:00
=dotspacemacs-configuration-layers= list.
* Concept
2017-06-06 10:24:30 +00:00
This package first switches the traditional ~hjkl~ movement keys, with their
equivalent keys in the destination layout. It then tries to correct the bugs,
that were introduced by these changes in other parts of Spacemacs. This layer
only tries to make these changes when the letters are used for *movements*.
2016-04-04 20:35:01 +00:00
The equivalent remapping is also made for uppercase letters, ~CTRL+KEY~,
2017-06-06 10:24:30 +00:00
~META+KEY~ and leader key bindings such as (~SPC …~), whenever it makes sense.
2016-04-04 20:35:01 +00:00
2017-06-06 10:24:30 +00:00
In some cases the remapped keys won't follow these conventions, mainly because
there are better alternatives, or because some movements don't make sense.
2016-04-04 20:35:01 +00:00
2017-06-06 10:24:30 +00:00
For example: In the =magit= status buffer, the ~c~ key is bound to =commit= by
default. If we want to follow the conventions, then it should be remapped to
"move left" in the bepo layout, but since operations in =magit= are done line by
line, then there's no reason to move left, and we won't remap the ~c~ key.
2016-04-04 20:35:01 +00:00
* Keyboard layouts
2017-06-06 10:24:30 +00:00
The following keyboard-layouts are available with this layer:
2016-04-04 20:35:01 +00:00
2017-06-06 10:24:30 +00:00
** Bepo
2016-04-04 20:35:01 +00:00
[[file:img/bepo-logo.png]]
Bepo is a keyboard layout that's optimized for the French language.
2016-04-04 20:35:01 +00:00
2017-06-06 10:24:30 +00:00
[[file:img/bepo-layout.png]]
2016-04-04 20:35:01 +00:00
The mapping correction is the one proposed for vim on the official Bepo [[http://bepo.fr/wiki/Vim#Principe][wiki]].
2016-04-04 20:35:01 +00:00
2017-06-06 10:24:30 +00:00
- The =bepo= layout: matches Vims movements keys:
2016-04-04 20:35:01 +00:00
- ~c → h~
- ~t → j~
- ~s → k~
- ~r → l~
2017-06-06 10:24:30 +00:00
- The lost keys are remapped as follows:
2016-04-04 20:35:01 +00:00
- ~h → r~
- ~j → t~
- ~k → s~
- ~l → c~
Some Bepo keys are not used in the traditional mapping, mainly because they are
2017-06-06 10:24:30 +00:00
not on the =en-us= keyboard layout. They are used as aliases for other
shortcuts:
2016-04-04 20:35:01 +00:00
2017-06-06 10:24:30 +00:00
- Map the unused ~é~ key as an alias for ~w~, it's more useful in vim mode:
2016-04-04 20:35:01 +00:00
- ~é → w~
- ~É → W~
2017-06-06 10:24:30 +00:00
- Map indentation to direct-access keys:
2016-04-04 20:35:01 +00:00
- ~» → >~
- ~« → <~
Some default configurations are also not optimal for vim, so the following
defaults are changed:
2017-06-06 10:24:30 +00:00
- Change the =evil-escape= combination to something that's faster to type, while
2016-04-04 20:35:01 +00:00
being nearly nonexistent in French or English words:
- ~fd → gq~
2017-06-06 10:24:30 +00:00
- In =avy=, the keys that select words/lines are remapped to the 8 characters
under the home row fingers:
2016-04-04 20:35:01 +00:00
- ~a u i e t s r n~
2017-06-06 10:24:30 +00:00
Note: There's one difference from the wiki version: ~w~ is *not* remapped to
~C-w~. This avoids having to change its meaning in other modes. Spacemacs
already provides ~SPC w~ for working with windows.
2016-04-04 20:35:01 +00:00
2017-06-06 10:24:30 +00:00
** Dvorak
Dvorak is a keyboard layout, that's optimized for the English language. It
2017-06-06 10:24:30 +00:00
rearranges the keys, to require less finger movements away from the home row.
2016-04-04 20:35:01 +00:00
2017-06-06 10:24:30 +00:00
The most common Dvorak layout is called Dvorak Simplified Keyboard (referred to
as just Dvorak keyboard or Dvorak layout). It comes pre-installed on most
operating systems.
/Dvorak Simplified Keyboard (US layout):/
2016-04-04 20:35:01 +00:00
2017-06-06 10:24:30 +00:00
[[file:img/dvorak-simplified-layout.png]]
/Programmer Dvorak:/
2017-06-06 10:24:30 +00:00
[[file:img/programmer-dvorak-layout.png]]
There's also a sub-layout called [[Https://www.kaufmann.no/roland/dvorak/][Programmer Dvorak]]. It reorders the number and
symbol keys, to make it easier to type common programming symbols, without
having to hold down the shift key. The keys that differ from the /Dvorak
Simplified Keyboard/ are shown in blue.
2017-06-06 10:24:30 +00:00
This Spacemacs Keyboard Layout layer has two Dvorak movement key variants:
The =dvp= variant: matches Vims movement keys:
- ~d → h~
- ~h → j~
- ~t → k~
- ~n → l~
The lost keys are remapped as follows:
- ~j → d~
- ~k → t~
- ~l → n~
The =dvorak= variant: uses the home row, which is shifted 1 key to the right of
Vims movement keys.
- ~h~ doesn't need to be remapped, it's already under the index finger.
- ~t → j~
- ~n → k~
- ~s → l~
The lost keys are remapped as follows:
- ~j → t~
- ~k → n~
- ~l → s~
** Colemak
Colemak is a modern alternative to the QWERTY and Dvorak layouts. It is designed
for efficient and ergonomic touch typing in English. More info can be found on
the [[https://colemak.com/][Colemak website]].
[[file:img/colemak-layout.png]]
This layer offers three flavors of Colemak bindings:
2017-06-06 10:24:30 +00:00
- =colemak-hnei= remaps ~HJKL~ to ~HNEI~, keeping the same key location; useful
for people used to the ~HJKL~ scheme on a Qwerty keyboard.
- =colemak-neio= remaps ~HJKL~ to ~NEIO~, shifted one key to the right for
easier access.
- =colemak-jkhl= remaps ~HJKL~ to ~JKHL~, permuting the direction of the keys
without disturbing any other binding.
*Note*: for technical reasons (see [[https://github.com/syl20bnr/spacemacs/pull/7178#issuecomment-249360301][GH-7178]]), when using =colemak-jkhl=, the
~kl/pre-config-evil~ and ~kl/post-config-evil~ hooks will be run /twice/.
** Workman
2017-06-06 10:24:30 +00:00
=Workman= is an English-optimized keyboard layout that's designed to, among
other things, reduce finger travel-distance, and balance the load equally
between hands. It is meant to function particularly well in conjunction with
ortholinear ('matrix' or 'grid') keyboards, such as the one depicted in the
diagram below. More information can be found in the [[https://en.wikipedia.org/wiki/Keyboard_layout#Workman][Workman section]], of the
wikipedia keyboard layout page.
2017-06-06 10:24:30 +00:00
[[file:img/workman-layout.png]]
2017-06-06 10:24:30 +00:00
As recommended in this blog post: [[Https://axiomatic.neophilus.net/posts/2013-08-13-workman-layout-for-vim.html][Workman layout for Vim]], this layout
substitutes the following keys with these mnemonics:
- (y)ank -> (h)aul
- Search (n)ext -> (j)ump
- (e)nd word -> brea(k) of word
- (o)pen new line -> (l)ine
2017-06-06 10:24:30 +00:00
- The lost keys are remapped as follows:
- ~h → y~
- ~j → n~
- ~k → e~
- ~l → o~
** Neo
Neo is a ergonomic keyboard that is optimized for German. More information can
be found on the [[https://www.neo-layout.org/][website]].
The Neo layout has six layers, here is only the first:
[[file:img/neo-layout.png]]
* Package Configurations
2016-04-04 20:35:01 +00:00
The available configurations are:
- ace-window
- avy
- comint
- company
- elfeed
- evil
- evil-escape
- evil-evilified-state
- evil-surround
- eyebrowse
- flycheck
- helm
- imenu-list
- ivy
- magit
- mu4e
- neotree
- org
- org-agenda
- ranger
- twittering-mode
2017-06-06 10:24:30 +00:00
* Key bindings
This layer tries to bind keys /automatically/ in a lot of modes. That makes it
difficult to list them all. For example the key bindings change if:
2016-04-04 20:35:01 +00:00
- You chose to use a different keyboard layout.
- You chose to be on the dark side by using evil (because they have :cookie: obviously).
- You chose to use a layer, written with :heart:, that try to solve the induced mess.
2016-04-04 20:35:01 +00:00
2017-06-06 10:24:30 +00:00
So the price you have to pay is the absence of a key bindings list.
* Image sources
- The keyboard-layout layer logo is a modified image from [[https://openclipart.org/detail/202777/keyboard-layout][openclipart.org]], and
is under the public domain.
- The Bepo logo and layout images, are from the official [[http://bepo.fr/][bepo]] website. (the
layout image has been modified).
- The Dvorak Simplified layout image is a modified image from [[https://en.wikipedia.org/wiki/File:KB_United_States_Dvorak.svg][Wikipedia]].
- The Programmer Dvorak layout image is a modified version of the Dvorak
Simplified layout image.
- The Colemak layout image is a modified version from [[https://en.wikipedia.org/wiki/File:KB_US-Colemak.svg][Wikipedia]].
They are all licensed under the [[https://creativecommons.org/licenses/by-sa/3.0/deed.en][CC-BY-SA]].