6

In any text editor, when I type
⌥ p it inserts π at cursor
⌥ w it inserts at cursor
Thus every key when pressed with option inserts some special character.

Question

How can I disable this ?

Why I want to disable this?

  1. I hardly use these symbols
  2. I am an hardcore emacs user, hence I always prefer shortcuts like
    • ^ A to move cursor to beginning, instead of Home
    • ^ n to next line, instead of
    • ^ K to kill line
      Thus I always use Control + Key for every navigation in text.
      But since mac has some other functionaly for Option + Key I cannot use some thing like, ⌥ w to copy region

Note: - The reason I love Mac over Linux apart from Crispy UI, is its native support to emacs shortcuts. If shortcut with option modifier work well every text editor will be emacs for me.

7

Save the following to ~/Library/KeyBindings/DefaultKeyBinding.dict (create if necessary).

{ "~a" = (); "~b" = (); "~c" = (); "~d" = (); "~e" = (); "~f" = (); "~g" = (); "~h" = (); "~i" = (); "~j" = (); "~k" = (); "~l" = (); "~m" = (); "~n" = (); "~o" = (); "~p" = (); "~q" = (); "~r" = (); "~s" = (); "~t" = (); "~u" = (); "~v" = (); "~w" = (); "~x" = (); "~y" = (); "~z" = (); }

This disables all the ⌥<letter> combinations. Restart apps to take effect.

The DefaultKeyBinding.dict above is an old-style property list1, defining key-value pairs using the syntax { key = value }. In this case, the keys are the key combinations to activate the method in the value.

Standard dictionary key symbols are used: ~ alt, ^ control, $ shift, @ command.
Therefore ~a means ⌥A (alt-A) and ^$1 would be ⌃⇧1 (control-shift-1).

The value for each of the keys is set to ()—empty parentheses without a method. As DefaultKeyBinding.dict overrides /S*/L*/Fr*/AppKit.*/R*/StandardKeyBinding.dict, the shortcut is defined to be without method and therefore does nothing. It's preferable to create your own key bindings file like this rather than editing the system one.

1 Feel free to use a new XML property list style if you prefer—it works the same.

  • I am extremely thankful. It was exactly what I wanted. BTW I would appreciate if you could explain what '~' and ( ) do. – Kaunteya Jul 18 '15 at 13:45
  • @Kaunteya Edited answer—does that help? – grg Jul 18 '15 at 13:56
  • 1
    Does this work for anyone on MacOs? (Sierra?) No effect for me.. – Alexandre G Jul 1 '17 at 7:27
0

For anyone finding this later and having problems with this.

I was unsuccessful doing this, and the other option with Ukelele has it's own problems (hard to remove default keyboard), so I ended up using BetterTouchTool to replace Option shortcuts with other actions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.