Cannot override command


#1

On OSX, I’m trying to override the cmd-right and cmd-left shortcuts but for some reason it’s not working. This is my keymap.cson file:

'.editor':
  'cmd-right': 'editor:move-to-end-of-word'
  'cmd-left': 'editor:move-to-beginning-of-word'

However, as seen below, the shortcuts are not applied.

Any idea why it’s not working?


#2

I don’t know why it isn’t working for you, I just copied and pasted your entries from your post here into my keymap.cson and it works for me:

Did you save the file before you went to the Settings screen? Which version of Atom are you using?


#3

Try body instead of .editor:

'body':
  'cmd-right': 'editor:move-to-end-of-word'
  'cmd-left': 'editor:move-to-beginning-of-word'

#4

Well actually it seems my custom shortcuts are partially broken. I have the following ones in my file:

'.editor':
  'cmd-right': 'editor:move-to-end-of-word'
  'cmd-left': 'editor:move-to-beginning-of-word'

'.platform-darwin':
  'alt-cmd-p': 'project-manager:toggle'

'.editor':
  'alt-cmd-p': 'project-manager:toggle'

'.editor':
  'f3': 'find-and-replace:find-next'
  'shift-f3': 'find-and-replace:find-previous'

Out of these, only the F3 shortcuts are still working. Alt-cmd-p and cmd-right/left used to work but now don’t anymore. Any idea how this can be debugged?

Also are there some temp files or cache that I could clear to try to restart Atom in a fresh way?


#5

Try this:

  1. Close all Atom instances
  2. Delete the ~/.atom/storage directory
  3. Launch Atom with atom --safe (this only loads the default packages)

Then see if it still is broken.


#6

I think I figured it out. It appears that Atom is only seeing the last .editor section, which would make sense since CSON is just a variant of JSON and when it gets loaded into a JavaScript Object there can only be one .editor key.

Changing things to this should work:

'.platform-darwin':
  'alt-cmd-p': 'project-manager:toggle'
'.editor':
  'f3': 'find-and-replace:find-next'
  'shift-f3': 'find-and-replace:find-previous'
  'cmd-right': 'editor:move-to-end-of-word'
  'cmd-left': 'editor:move-to-beginning-of-word'
  'alt-cmd-p': 'project-manager:toggle'

You can always use the Key Binding Resolver (Cmd+.) to find out how Atom interprets the keys you press:


#7

Yes that was it, thanks leedohm! I was indeed editing the file as if it was CSS instead of CSON.