How to avoid Repeated Strain Injury when using emacs by re-assigning hotkeys
I've read all the Emacs RSI related articles from the internet.
Typical solutions are:
- buy special hardware
- remap ctrl key (because Emacs users press Ctrl key too often)
- use Vi key binding
- other Emacs keybinding with some hacking
- voice input
I will discuss the third item "use Vim key binding" because there is still room to improve.
Here is my observation. Even I use Vi keybinding, there are top three frequently pressed keys which may hurt my left hand:
These top three need me move my left hands too often. That may be the problem of RSI. In this case, A little knowledge of Vim will help.
In vi, we use key combination start with <leader> key. The leader key is actually the comma key =,=.
As you can see, comma key is close to the right hand fingers. So using key combination with leader key as the first key to press will give more spare hot keys to replace
The principle here is DO NOT move hands at all. Following this example, I can figure out many practical solution.
(require 'evil-leader) (evil-leader/set-key "xf" 'ido-find-file "xb" 'ido-switch-buffer "xc" 'save-buffers-kill-terminal "jj" 'w3mext-search-js-api-mdn "xz" 'suspend-frame "xvv" 'vc-next-action "xv=" 'vc-diff "xvl" 'vc-print-log)
On some keyboard, the
Alt key is easy to press because it's big and just under the big thumb. So I can assign some key combination like
M-k to replace
k is also close to my fingers. Here is my setup in
(global-set-key (kbd "M-k") 'keyboard-quit) (define-key evil-insert-state-map (kbd "M-k") 'evil-normal-state) (define-key evil-visual-state-map (kbd ",k") 'evil-exit-visual-state) (define-key minibuffer-local-map (kbd ",k") 'abort-recursive-edit) (define-key evil-insert-state-map (kbd "M-j") 'yas-expand)
Some minor modes will re-assign the hot key
C-g, so when I say replace
C-g with =,k=. It may be a bit more elisp code:
;; the original hot key of helm-keyboard-quit is "C-g" (define-key helm-map (kbd ",k") 'helm-keyboard-quit)
The key point is to understand the principles instead copy my configuration:
- comma is a good key for hot key prefix, it's used by vi users for ages
- use keys close to fingers (L,J,K,L, for example) in hot keys
- Other keys close to right hand is also useful in key combinations
- Avoid move left hand