Advertisement
Guest User

Fixing Emacs Default Keybinds

a guest
Jun 29th, 2019
2,231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.25 KB | None | 0 0
  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 an xmodmap file:
  28. Save as ~/.Xmodmap
  29.  
  30. ! Swap Ctrl and Alt
  31. clear control
  32. clear mod1
  33. keycode 37 = Alt_L Meta_L
  34. keycode 105 = Alt_R Meta_R
  35. keycode 64 = Control_L
  36. keycode 108 = Control_R
  37. add control = Control_L Control_R
  38. add mod1 = Alt_L Meta_L
  39.  
  40. or
  41.  
  42. ! Swap Ctrl and Capslock
  43. remove Lock = Caps_Lock
  44. remove Control = Control_L
  45. keysym Control_L = Caps_Lock
  46. keysym Caps_Lock = Control_L
  47. add Lock = Caps_Lock
  48. add Control = Control_L
  49.  
  50. Then run `xmodmap ~/.Xmodmap`
  51. Note: you probably want to auto-execute this when your X session starts
  52.  
  53. --------------------
  54.  
  55. In Emacs only:
  56. ;; Swap Ctrl and Alt
  57. ;; V26+, X11 only
  58. (setq x-ctrl-keysym 'meta)
  59. (setq x-meta-keysym 'ctrl)
  60.  
  61. Note that many terminal binds are the same as emacs, so doing it only in emacs as opposed to globally would lead to inconsistency.
  62. For more info see https://www.gnu.org/software/emacs/manual/html_node/elisp/X11-Keysyms.html
  63.  
  64. ------------------------------------------------------------
  65.  
  66. 3. Use an external package
  67.  
  68. evil-mode: Probably the most common, as vim keys are pretty widespread and many migrants to emacs are already used to them.
  69. evil-collection and evil-escape are also nice mentions, as they make the vim experience a lot more consistent.
  70. The downside of course is that you're removing the "emacs"ness of keybinds, many prefer to stay more vanilla.
  71.  
  72. --------------------
  73.  
  74. god-mode: Unlike evil, this keeps all of emacs's keys intact, you simple map a GOD-KEY to type commands more easily.
  75. You simply hit your configured key, then every key you hit afterwards has C- prefixed to it.
  76. SPC- lets you remove C-.
  77. So <C-x> <C-f> becomes GOD-KEY x f
  78. And <C-x> b becomes GOD-KEY x SPC b
  79.  
  80. --------------------
  81.  
  82. xah-fly-keys: For the more adventurous, following neither emacs defaults nor vim, it maps keys on a usage based scheme.
  83. see for more info: http://ergoemacs.org/misc/ergoemacs_vi_mode.html
  84.  
  85. ------------------------------------------------------------
  86.  
  87. Other links:
  88.  
  89. https://www.emacswiki.org/emacs/MovingTheCtrlKey
  90. https://www.emacswiki.org/emacs/RepeatedStrainInjury
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement