SHOW:
|
|
- or go back to the newest paste.
| 1 | Emacs's default keybinds are of some infamy, and RSI memes abound aplenty. | |
| 2 | The simple fact is that they are not very ergonomic, at least not for modern keyboard layouts. | |
| 3 | ||
| 4 | Luckily there's a few ways to remedy this situation. | |
| 5 | ||
| 6 | ------------------------------------------------------------ | |
| 7 | ||
| 8 | 1. Ignore the issue entirely and pretend everything is okay | |
| 9 | ||
| 10 | Alternatively, get yourself some foot pedals... | |
| 11 | https://www.emacswiki.org/emacs/FootSwitches | |
| 12 | ||
| 13 | ------------------------------------------------------------ | |
| 14 | ||
| 15 | 2. Remap Ctrl to another button | |
| 16 | ||
| 17 | There were keyboards designed for writing lisp: https://upload.wikimedia.org/wikipedia/commons/4/47/Space-cadet.jpg | |
| 18 | You'll notice that Ctrl, the most commonly used modifier key is also the closest to the spacebar. | |
| 19 | This means you can easily hit Ctrl with your thumb, instead of modern keyboards where you'll be straining to stretch your pinky to hit it. | |
| 20 | ||
| 21 | Swapping Alt and Ctrl is common. | |
| 22 | As is swapping Ctrl and Caps Lock (though it has some issues http://ergoemacs.org/emacs/swap_CapsLock_Ctrl.html). | |
| 23 | You can do this at the OS level with xmodmap, or internally in emacs if you don't want to fuck up your other keybinds. | |
| 24 | ||
| 25 | -------------------- | |
| 26 | ||
| 27 | Globally via setxkbmap: | |
| 28 | setxkbmap -option ctrl:swapcaps | |
| 29 | or | |
| 30 | setxkbmap -option ctrl:swap_lalt_lctl | |
| 31 | - | You may also want to have Caps Lock as Ctrl and Ctrl as Hyper key: |
| 31 | + | |
| 32 | You may also want to have Caps Lock as Ctrl and Ctrl as Hyper key (Hyper key can be used for shortcuts, "H-n" means "Hyper+n"): | |
| 33 | setxkbmap -option ctrl:swapcaps_hyper | |
| 34 | ||
| 35 | More information: man setxkbmap and man xkeyboard-config | |
| 36 | Note: you probably want to auto-execute this when your X session starts | |
| 37 | ||
| 38 | -------------------- | |
| 39 | ||
| 40 | Globally via X.Org configuration file: | |
| 41 | 1. Create and edit /etc/X11/xorg.conf.d/00-keyboard.conf | |
| 42 | 2. Paste the following: | |
| 43 | ||
| 44 | Section "InputClass" | |
| 45 | Identifier "system-keyboard" | |
| 46 | MatchIsKeyboard "on" | |
| 47 | Option "XkbOptions" "swapcaps" | |
| 48 | EndSection | |
| 49 | ||
| 50 | 2.1 Put your own setxkbmap option instead of "swapcaps" on line 4 if you need it. | |
| 51 | 3. Restart X.Org or reboot. | |
| 52 | ||
| 53 | -------------------- | |
| 54 | ||
| 55 | Globally via an xmodmap file: | |
| 56 | Save as ~/.Xmodmap | |
| 57 | ||
| 58 | ! Swap Ctrl and Alt | |
| 59 | clear control | |
| 60 | clear mod1 | |
| 61 | keycode 37 = Alt_L Meta_L | |
| 62 | keycode 105 = Alt_R Meta_R | |
| 63 | keycode 64 = Control_L | |
| 64 | keycode 108 = Control_R | |
| 65 | add control = Control_L Control_R | |
| 66 | add mod1 = Alt_L Meta_L | |
| 67 | ||
| 68 | or | |
| 69 | ||
| 70 | ! Swap Ctrl and Capslock | |
| 71 | remove Lock = Caps_Lock | |
| 72 | remove Control = Control_L | |
| 73 | keysym Control_L = Caps_Lock | |
| 74 | keysym Caps_Lock = Control_L | |
| 75 | add Lock = Caps_Lock | |
| 76 | add Control = Control_L | |
| 77 | ||
| 78 | Then run `xmodmap ~/.Xmodmap` | |
| 79 | Note: you probably want to auto-execute this when your X session starts | |
| 80 | ||
| 81 | -------------------- | |
| 82 | ||
| 83 | In Emacs only: | |
| 84 | ;; Swap Ctrl and Alt | |
| 85 | ;; V26+, X11 only | |
| 86 | (setq x-ctrl-keysym 'meta) | |
| 87 | (setq x-meta-keysym 'ctrl) | |
| 88 | ||
| 89 | Note that many terminal binds are the same as emacs, so doing it only in emacs as opposed to globally would lead to inconsistency. | |
| 90 | For more info see https://www.gnu.org/software/emacs/manual/html_node/elisp/X11-Keysyms.html | |
| 91 | ||
| 92 | ------------------------------------------------------------ | |
| 93 | ||
| 94 | 3. Use an external package | |
| 95 | ||
| 96 | evil-mode: Probably the most common, as vim keys are pretty widespread and many migrants to emacs are already used to them. | |
| 97 | evil-collection and evil-escape are also nice mentions, as they make the vim experience a lot more consistent. | |
| 98 | The downside of course is that you're removing the "emacs"ness of keybinds, many prefer to stay more vanilla. | |
| 99 | ||
| 100 | -------------------- | |
| 101 | ||
| 102 | god-mode: Unlike evil, this keeps all of emacs's keys intact, you simple map a GOD-KEY to type commands more easily. | |
| 103 | You simply hit your configured key, then every key you hit afterwards has C- prefixed to it. | |
| 104 | SPC- lets you remove C-. | |
| 105 | So <C-x> <C-f> becomes GOD-KEY x f | |
| 106 | And <C-x> b becomes GOD-KEY x SPC b | |
| 107 | ||
| 108 | -------------------- | |
| 109 | ||
| 110 | xah-fly-keys: For the more adventurous, following neither emacs defaults nor vim, it maps keys on a usage based scheme. | |
| 111 | see for more info: http://ergoemacs.org/misc/ergoemacs_vi_mode.html | |
| 112 | ||
| 113 | -------------------- | |
| 114 | ||
| 115 | Different typing technique: press Ctrl key with your palm, next to the base of your finger. Use modifiers on both sides of the keyboard (one hand shouldn't type a key and hold down a modifier at the same time) if it feels awkward. | |
| 116 | Note: this is not possible on low profile, flat keyboards that you'll find on laptops and some rubber dome keyboards such as Logitech K810. | |
| 117 | ||
| 118 | OR | |
| 119 | ||
| 120 | Use both Ctrl keys and use your ring/middle/index fingers instead of the pinky. | |
| 121 | ||
| 122 | -------------------- | |
| 123 | ||
| 124 | Sticky keys via xkbset. The advantage to this is that you don't have to hold down a key. | |
| 125 | xkbset sticky -twokey latchlock ## set sticky keys, don't disable via twokey | |
| 126 | ||
| 127 | More info in the man pages. | |
| 128 | -------------------- | |
| 129 | ||
| 130 | Other links: | |
| 131 | ||
| 132 | https://www.emacswiki.org/emacs/MovingTheCtrlKey | |
| 133 | https://www.emacswiki.org/emacs/RepeatedStrainInjury |