3

Not your average keybinding question...

Is there any way to completely and without mercy remove or unset the Emacs keybindings on the Mac?

After much research I come to you with a problem and what I have learned:

Problem -- I want my basic shortcuts (like copy & paste) to be like Windows, with the Control key instead of the Command key.

I could swap the Modifier keys in Keyboard Settings. But this is problematic for me, because much of the time I'm remoting into Windows machines. When I swap the modifier keys on the iMac system, they are reversed again as soon as I remote into Windows.

So what I have done instead is to add custom shortcuts in Keyboard Settings. This mostly works, and works perfect remoted into a Windows machine. But there is one part of this setup that still doesn't work right:

In certain text editors or text-fields on web-based forms, or instant messaging apps where you are type into a field (basically any time you are editing raw text) the Control-V does not work for Paste, even when the custom shortcut for it exists.

Instead of pasting, it moves the cursor to the end of the current view. I've learned that this is one of many "Emacs" keybindings that are intentionally built into Macs. Emacs is a raw text editor, and these keybindings come into play when you are inside a raw text editing environment. Basically, a different shortcut is taking precedence over my custom one. This behavior can be reproduced by adding the custom shortcut and attempting to paste with it in Apple's own TextEdit.

After even more research, I've discovered that these Emacs Keybindings can be unset by adding/editing a DefaultKeyBinding.dict file using such syntax as { "^v" = ( ); } -- which I've done and....well, it works...for some things. It seems to have fixed the issue for native OS apps such as TextEdit, but still won't paste (and it still moves the cursor to the end) in most web form fields and web-based editing programs. And it's extremely frustrating.

3
  • The last line needs to be the first (or maybe second) line in this question. Your reaseach also needs to show what you understand can be done in emacs not just using mac system preferences. Most google for mac and emacs keybindings will show ways of doing this.
    – mmmmmm
    Jan 24, 2022 at 14:42
  • Thanks I will move the last line to the top. No amount of incessant googling for mac and emacs keybindings has yielded much that is helpful, because most such discussions are about how to use or enable these keybindings, while I want to remove or disable them. Jan 24, 2022 at 18:33
  • Look for emacs keybindings in emacs own help gnu.org/software/emacs/manual/html_node/elisp/…
    – mmmmmm
    Jan 24, 2022 at 18:38

2 Answers 2

2

This will be a massive amount of work due to how Apple designed the text handling routines all across its developer tools.

Nothing is truly impossible, but the lift here will be enormous to somehow “hot patch all of the code” everywhere. I believe you’ve done a good job isolating which easy fixes are available and now have the harder nuts to crack, application by application.

4
  • Thank you for understanding what I'm trying to do 👍 Jan 24, 2022 at 23:50
  • I get it my friend. To assign new shortcuts over ones you don’t like is far easier than removing the presence of them - and it’s several places in the code AFAIK that all need changing without breaking anything else.
    – bmike
    Jan 25, 2022 at 1:18
  • 1
    The Ctrl-v, Ctrl-x, Ctrl-c commands are from Apple II, not from Emacs (as Emacs's equivalent of those are Ctrl-y for yank, Ctrl-W, and Meta/Esc-W, respectively). The Emacs commands that appear in MacOS X since acquisition of NeXT are Ctrl-n for next line, Crtl-p for previous line, Ctrl-b for backward to the left, Ctrl-f for forward to the right. You might want to “completely & mercilessly remove” those Emacs-proper commands too, but the wrath of your question is aimed at the incorrect history: not Emacs out of MIT, but rather Apple II out of Cupertino. Jan 29, 2022 at 17:38
  • Agreed @AndreasZUERCHER emacs is so, so much more than “a raw text editor” and the various influences, heresies and standards are almost as rich as the “holy wars” between students of the vi/emacs regimes.
    – bmike
    Jan 29, 2022 at 17:41
0

I don't believe this is possible natively. However, if you are open to using a third-party tool, I believe Keyboard Maestro is flexible enough to remap any key to any action. I'm sure other key-mapping tools can do the same.

Regarding your comment on customizing DefaultKeyBinding.dict, here is a good summary of the OS Text System and default bindings, along with details on how to customize DefaultKeyBinding.dict. That file is essentially a mapping of keyboard shortcuts to NSResponder methods, described here, but you can see that none of the methods include anything like a "paste from clipboard" option.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .