Why do user key-bindings not take priority


#1

Why do user key-bindings not take priority off system key bindings.

i.e I added a key binding for indenting code

Shouldn’t MY key bindings be more important?

I get no formatting and stupid fold-selection (fold-selection when there is no selection… might I add, another bug…)


#2

I wonder what it means that they both have checkmarks.


#3

Because they use rule structure’s similar to CSS.

http://www.w3.org/TR/CSS2/cascade.html#specificity

Tbh I don’t 100% understand the link above. I usually play it by ear through testing. But essentially, the more specific rule wins.

.editor can have any parent, but .workspace .editor will only apply to .editors which are inside a .workspace, which is more specific. Basically, the higher up in the DOM you specify from, the higher the order of precedence.


#4

You can also learn about keymaps and specificity in the official documentation:

https://atom.io/docs/latest/advanced/keymaps


#5

This is just way too complicated. I just want to override a binding, not learn about unsetting existing bindings…


#6

Your specified key binding rule is less specific than the built-in one; just make yours as specific as the built-in key binding

'.workspace .editor:not(.mini)':
  'ctrl-alt-f': 'editor:auto-indent'

#7

What about this one?

As you can see, my keybinding is more specific, and still is being overriden by the editor…


#8

What if you just do ink-console atom-text-editor?


#9

Same error

I’m using atom 1.9.8


#10

If you have steps to reproduce the problem, please open an Issue on https://github.com/atom/atom-keymap and @-mention me on it. I’ll have the team take a look.


#11

There was already an issue open, so I’ve added to it: https://github.com/atom/atom-keymap/issues/138.

Let me know if it’s better to open a new one.

Thanks!