Keymap change not working


#1

I’ve been using ST2 and just switched to Atom … love it!

I am trying to override two Atom key bindings - move line up / down - which I am used to using in ST2.

In my keymap I added …

'atom-workspace atom-text-editor:not([mini])':
  'alt-cmd-down': 'editor:move-line-down'
  'alt-cmd-up': 'editor:move-line-up'

… however they don’t work. If I change them to …

'atom-workspace atom-text-editor:not([mini])':
  'alt-down': 'editor:move-line-down'
  'alt-up': 'editor:move-line-up'

… they work fine. I’ve looked for conflicts and can’t find any that would prevent this from working. Does anyone have any ideas?

Thanks!
Chris


#2

Have you tried using the Keybinding Resolver Cmd+. to see what key combination Atom thinks you’re pressing?


#3

Thanks for the quick reply!

That’s awesome. It shows …

symbols-view:return-from-declaration  .platform-darwin .editor

I’m not sure what that is, or why my user key binding is not overriding it. But I’m happy to know how to find key binding conflicts!

Chris


#4

Atom’s keybinding system is based on CSS. As such, it uses the same specificity rules that CSS does:

https://atom.io/docs/latest/advanced/keymaps#specificity-and-cascade-order

In order to win, your keybinding needs to be at least as specific as the one you’re trying to beat. Classes beat tags, so you might want to use:

'.platform-darwin .editor':
  'alt-cmd-down': 'editor:move-line-down'
  'alt-cmd-up': 'editor:move-line-up'

#5

Awesome. That worked great. Thanks for the help and the link!


#6

This wording, “In order to win, your keybinding needs to be at least as specific as the one you’re trying to beat.”, sounds like CSS selectors and is in fact the key thing to think about. This should be in the manual written like this. Exactly.


#7

It’s not literally those words, but it is specified exactly that explicitly.