Guest User

Untitled

a guest
Dec 29th, 2020
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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:
  32. setxkbmap -option ctrl:swapcaps_hyper
  33. More information: man setxkbmap and man xkeyboard-config
  34. Note: you probably want to auto-execute this when your X session starts
  35.  
  36. --------------------
  37. Globally via X.Org configuration file:
  38. 1. Create and edit /etc/X11/xorg.conf.d/00-keyboard.conf
  39. 2. Paste the following:
  40.  
  41. Section "InputClass"
  42. Identifier "system-keyboard"
  43. MatchIsKeyboard "on"
  44. Option "XkbOptions" "swapcaps"
  45. EndSection
  46.  
  47. 2.1 Put your own setxkbmap option instead of "swapcaps" on line 4 if you need it.
  48. 3. Restart X.Org or reboot.
  49. --------------------
  50.  
  51. In Emacs only:
  52. ;; Swap Ctrl and Alt
  53. ;; V26+, X11 only
  54. (setq x-ctrl-keysym 'meta)
  55. (setq x-meta-keysym 'ctrl)
  56.  
  57. Note that many terminal binds are the same as emacs, so doing it only in emacs as opposed to globally would lead to inconsistency.
  58. For more info see https://www.gnu.org/software/emacs/manual/html_node/elisp/X11-Keysyms.html
  59.  
  60. ------------------------------------------------------------
  61.  
  62. 3. Use an external package
  63.  
  64. evil-mode: Probably the most common, as vim keys are pretty widespread and many migrants to emacs are already used to them.
  65. evil-collection and evil-escape are also nice mentions, as they make the vim experience a lot more consistent.
  66. The downside of course is that you're removing the "emacs"ness of keybinds, many prefer to stay more vanilla.
  67.  
  68. --------------------
  69.  
  70. god-mode: Unlike evil, this keeps all of emacs's keys intact, you simple map a GOD-KEY to type commands more easily.
  71. You simply hit your configured key, then every key you hit afterwards has C- prefixed to it.
  72. SPC- lets you remove C-.
  73. So <C-x> <C-f> becomes GOD-KEY x f
  74. And <C-x> b becomes GOD-KEY x SPC b
  75.  
  76. --------------------
  77.  
  78. xah-fly-keys: For the more adventurous, following neither emacs defaults nor vim, it maps keys on a usage based scheme.
  79. see for more info: http://ergoemacs.org/misc/ergoemacs_vi_mode.html
  80.  
  81. ------------------------------------------------------------
  82.  
  83. Other links:
  84.  
  85. https://www.emacswiki.org/emacs/MovingTheCtrlKey
  86. https://www.emacswiki.org/emacs/RepeatedStrainInjury
Advertisement
Add Comment
Please, Sign In to add comment