Disable default keybindings


This works for me:

On keymap.cson (user keymap):

'.platform-win32 .editor':
  'ctrl-alt-q': 'unset!'
  'ctrl-alt-w': 'unset!' 

The catch here is the ‘unset!’ value to disable the keybinding

1 Like

Shortcut for folding code

To make this work for me, I had to use 'unset!' on the other side of key-value pair. Eg to remove the default binding of ctrl-shift-S from “Save As…” and then map ctrl-shift-S to “Save All”, this worked for me:

'.workspace .editor:not(.mini), .workspace':
  'ctrl-shift-S': 'window:save-all'

  # Without this, ctrl-shift-S triggers "Save As..."
  'unset!': 'core:save-as'
1 Like


You don’t need both rules to override Ctrl+Shift+S. You could just use:

  'ctrl-shift-s': 'window:save-all'


:white_check_mark: I wanted to disable the cmd-up/down shortcut so I added the following to my key binding file:

  'cmd-up': null
  'shift-cmd-up': null
  'cmd-down': null
  'shift-cmd-down': null

'body .native-key-bindings':
  'cmd-up': null
  'cmd-down': null

'body .native-key-bindings':
  'shift-cmd-up': null
  'shift-cmd-down': null


It seems to be working for now.



Agree with lukasoppermann about the override. I tried to override cmd-b cmd-r to what I usually use to run applications, didn’t work very well :frowning:



I’m having the same issue and I don’t know how to solve it.

I used cmd+shift+e for HTML encoding, but Emmet uses it for expanding abbreviation.

If I use unset! it disables the shortcut completely.
'cmd-shift-e': 'unset!'

If I don’t, Emmet takes precedence over Atom commands.

If I leave the second field empty, nothing happens.
'cmd-shift-e': ''

I don’t want to edit Emmet package since I will have to do that every time I update Emmet.

There should be a way of disabling a keymap on the package config. Even better, if a new package is installed and it conflicts with other keymaps the user should be notified and those conflicting keymaps automatically disabled.



If you use the same selector that Emmet uses for its keybinding and then change the command, it will work. From the Emmet package:

'.platform-darwin atom-text-editor:not([mini])':
  'cmd-shift-e': 'emmet:expand-abbreviation'

So if you put the following in your keymap.cson:

'.platform-darwin atom-text-editor:not([mini])':
  'cmd-shift-e': '[your desired command goes here]'

That should override it with no problem.



Hey @leedohm thanks. It works!

I really don’t understand the logic of those selectors. I thought those were to scope the commands to a certain package… how come I can edit an .atom-text-editor command into .platform-darwin atom-text-editor:not([mini]) ? Doesn’t that make those selectors pointless?



Commands are actually independent of packages. atom-text-editor here is a css selector and nothing more.



Keybindings are mapped using CSS selectors. So if I only want a keybinding to work on a certain type of text editor or I only want a keybinding to work on OS X (i.e. platform-darwin), I can just change the selector.



I came across a similar problem.
As a beginner in atom I want to mention a few more details that helped me solve the problem
that don’t seem obvious.

The configuration in keymap.cson overrides any default configuration so if
you unset a binding there the respective shortcut will do nothing.

To access that file you can first open settings with ctrl+, and then find a link to it in Keybindings.

In case your command binding is overridden by some other command, first
use the search field in Keybindings tab, where you can search both keystrokes, commands and packages.
After you find which commands you want to change and their keybindings
you need to add some lines at the end of keymap.cson in this format

  '<keybinding1>': '<command1>'
  '<keybinding2>': '<command2>' 

In any case information in keymap.cson can help further.



This worked like a charm!



Thank you. Now I am able to type the pipe character again (alt-h on Icelandic keymap on macOS)



There seems to be a great variety of suggestions, none of which quite worked for me to override ctrl-tab. I don’t like the behaviour of switching to recently used tabs; I prefer to use them in visible order as per pane:show-next-item. My successful config is:

  'ctrl-tab': 'unset!'
  'ctrl-shift-tab': 'unset!'
  'ctrl-tab': 'pane:show-next-item'
  'ctrl-shift-tab': 'pane:show-previous-item'

Thereby removing the existing keybindings from body and adding new keybindings that are ostensibly also in body. The choice of :not([override-impossible]) is an arbitrary one that matches as a css selector for body but with higher precedence (and without duplicate keys).

Hope this override pattern helps others.



The recommended solution is listed in the FAQ:

1 Like


Thanks @leedohm, I missed the FAQ, I should have done more searching. Now I get what the ^ctrl bindings are.



Today I’ve downloaded atom after formatting my machine (Atom 1.13.0 on Windows 7 64-bit), and when adding my keymap.cson file I got the message:

Failed to load C:\Users\Stavo\.atom\keymap.cson
Duplicate key 'ctrl-tab'


	'ctrl-tab ^ctrl':'unset!'
	'ctrl-shift-tab ^ctrl':'unset!'

Did the way to do this change?



The Atom FAQ has the canonical reference for how to do what it looks like you’re attempting to do:



After removing the lines:


Like in the FAQ, it no longer shows the error, but it shows that the key is used multiple times in the key resolver

Should I worry the other is showing, or only the line highlighted in green is used?



Only the green highlighted one is used.

1 Like