Can't override F2 keybinding


This thing is driving me crazy…
I have installed the refactor package, I’d like to remap the command refactor:rename to f2 key, but there’s no way to make it work.
There is another command mapped to f2, called bookmarks:jumpt-to-next-bookmark. trying to override the command in keymap.cson doesn’t have any effect. The keybinding resolver doesn’t even show it. If I correctly understand how it works, it should be at least show me the command is not executed because it’s overridden. Keybinding resolver says the association is made in a file which is actually empty.

Here’s what I’ve appended to keymap.cson

  'f2': 'refactor:rename'

I don’t know how to define a more specific selector, and I find frustrating having to learn the markup structure of my editor to just define some keybindings.

Is there something I’m not seeing?


Is there another 'atom-‘text-editor’ later in the file? If so the second will overwrite the first. Check the faq.


Have you tried using the Keybinding Resolver (Cmd+. on OS X and Ctrl+. on other platforms)? It will show you what key Atom saw you press and the command that was triggered because of it.


No, it’s the only one


Yes, I tried, but as I wrote in the post “The keybinding resolver doesn’t even show it”. Atom seems to completely ignore the new definition.


If the keybinding resolver doesn’t show it at all, then I would have to think that it isn’t in the right place or there is something else blocking it from being read. The keybinding resolver is designed to show all keybindings for the key combination pressed even if they don’t “win”.

When you attempted to activate the keybinding, was the focus on a text editor?


I moved the declaration before this other:

  'ctrl-shift-S': 'window:save-all'
  'alt-1': ''
  'alt-2': ''
  'alt-3': ''
  'alt-4': ''
  'alt-5': ''
  'alt-6': ''
  'alt-7': ''
  'alt-8': ''
  'alt-9': ''

And now it works. Why? :sweat_smile:


Could you post your entire keymap.cson in a Gist or something? We might be able to answer better seeing everything.


Well the problem was setting those keybindings to '', which apparently caused the entire keymap.cson to be ignored. I’ll open an issue on GitHub (invalidating the entire file should at least raise an error).

Thanks @leedohm for your care.