Disable Cmd-w on MacOS Catalina
Cmd-w closes the current window on MacOS Catalina. This conflicts with my muscle memory of using M-w in Emacs.
I looked at Disable Command-W in the terminal, but the accepted answer does not work on MacOS Catalina.
How do you disable Cmd-w?
Solution 1:
Like in old versions, it be can't removed. The work around is the same: the system default can be overridden to a new key combination. The hotkey must be associated with a context menu item name (ie. an app specific menu item). The name must match exactly.
Systems apps use the name Close
to mean close window, along with iTerm2. Some other apps use the more verbose Close Window
. Remap both to get decent app coverage. Note that some apps may use other unique names that mean close window. Separate entries will have to be made for these apps to remap it globally.
Navigate to System Preferences
-> Keyboard
.
Select the Shortcuts
tab, then App Shortcuts
in the left pane.
Select the +
at the bottom of the window to add a new shortcut.
To remap it globally, select All Applications
in the Application
field. To change Cmd-w on a specific application instead of globally, select that instead.
Set Menu Title
to Close
. It is case sensitive and must match exactly.
Set Keyboard Shortcut
to the desired key combination. I set it to an obscure value so it's essentially 'disabled'.
Click Add
to finalize the key shortcut. The right pane should now show a new entry for Close
with your key combination (see the first image for an example).
Add another hotkey entry with Application
set to All Applications
and Menu Title
set to Close Window
for additional coverage.
Close the menu.
The change takes effect immediately, including with open apps.