A Better Meta Key for Emacs
Saturday, April 26, 2025
Table of Contents
I'm going to show you how I made my use of the Meta
key much more ergonomic, and without making compromises like sacrificing precious home-row keys.
Semicolon as Meta
Emacs famously makes use of some less-than-ergonomic modifier keys, and for a long time, I just accepted the use of the Meta
key being somewhat uncomfortable1. But I recently discovered a better way—using the ;
key, but without sacrificing the ability to use ;
the normal way. When I simply enter ;
, it inserts a ;
at the cursor. Likewise, if I do some key combination like C-x C-;
, it still works as normal. But if I start with ;
and keep it held, my computer treats it as though I was holding down the right option key. For instance, ;-x
acts like M-x
and C-;-f
acts like C-M-f
.
Implementation with Karabiner Elements
I'm going to show you how I do this using Karabiner Elements. (If you're not on MacOS you can achieve the same results using alternatives like KMonad or Kanata). For simple modifications like swapping Capslock with Control, it is sufficient to select from a few drop-downs in the app, but for our purpose, you'll need to roll up your sleeves and edit some JSON.
After installing Karabiner Elements, you should have the file ~/.config/karabiner/karabiner.json
which is where your keyboard modifications are stored. You'll need to add an entry, "complex_modifications"
under { "profiles": [ {
.
"complex_modifications": { "rules": [ { "description": "Post semicolon if semicolon is pressed alone, right_option otherwise", "manipulators": [ { "from": { "key_code": "semicolon", "modifiers": { "optional": ["any"] } }, "to": [{ "key_code": "right_option" }], "to_if_alone": [{ "key_code": "semicolon" }], "type": "basic" } ] } ] }
Of course, you might have different needs/preferences, but hopefully the snippet above gives you some understanding of how to go about it.
My Karabiner Config
{ "profiles": [ { "complex_modifications": { "rules": [ { "description": "Post escape if caps is pressed alone, left_ctrl otherwise", "manipulators": [ { "from": { "key_code": "caps_lock", "modifiers": { "optional": ["any"] } }, "to": [{ "key_code": "left_control" }], "to_if_alone": [{ "key_code": "escape" }], "type": "basic" } ] }, { "description": "Post semicolon if semicolon is pressed alone, right_option otherwise", "manipulators": [ { "from": { "key_code": "semicolon", "modifiers": { "optional": ["any"] } }, "to": [{ "key_code": "right_option" }], "to_if_alone": [{ "key_code": "semicolon" }], "type": "basic" } ] } ] }, "devices": [ { "identifiers": { "is_keyboard": true, "product_id": 16400, "vendor_id": 12625 }, "simple_modifications": [ { "from": { "apple_vendor_top_case_key_code": "keyboard_fn" }, "to": [{ "key_code": "right_option" }] } ] }, { "identifiers": { "is_keyboard": true, "product_id": 591, "vendor_id": 1452 }, "simple_modifications": [ { "from": { "key_code": "left_command" }, "to": [{ "key_code": "left_option" }] }, { "from": { "key_code": "left_option" }, "to": [{ "key_code": "left_command" }] }, { "from": { "key_code": "right_control" }, "to": [{ "key_code": "right_option" }] } ] } ], "name": "Default profile", "selected": true, "virtual_hid_keyboard": { "country_code": 0, "keyboard_type_v2": "ansi" } } ] }
If you peruse my config above you may notice I've also made it so that Caps Lock acts as Control when held and Escape when pressed. In Emacs, pressing Esc
without necessarily holding it acts as holding alt/option, so Esc x
is equivalent to M-x
. This is useful in a terminal where the alt/option key may not be available to you. And some keybindings are just easier this way, like M-:
. Plus, if you use modal editing modes like Evil or Meow, it's handy to have Esc
close by without giving up easy access to Control
.
Footnotes:
Depending on your keyboard layout, it might not be so bad. On a PC, the ALT
key sits conveniently next to the space bar. On a Mac, it's a bit more awkward. Some Emacsers use Command as the Meta key, but that's a significant compromise because Command is quite useful in it's own right. So I've just been contorting my pinky to touch right-option until recently.