Use same keybinding as command (and override it)?


#1

Is it possible to explicitly use the same keybinding as a certain command, in order to override it no matter what its keybinding is? For example, say you had a command you wanted to override find-and-replace:show:

'.platform-darwin':
  'cmd-f': 'find-and-replace:show'
  'cmd-f': 'my-package:show'

Is it possible to specify "the same keybinding as find-and-replace-show" instead of writing the keybinding itself (which could change)? Something like:

'.platform-darwin':
  'cmd-f': 'find-and-replace:show'
  'find-and-replace:show': 'my-package:show'

?


#2

No, not the way the system is currently designed.


#3

You can use KeymapManager::findKeyBindings to find out the key-combo bound to a command. Then use that information to write to a keymap file that you are watching with KeymapManager::watchKeymap.

You can also overwrite the find-and-replace:show command:

atom.commands.add 'find-and-replace:show', ->
  // code you want to run on 'find-and-replace:show'

This way it can be a bit tricky which package’s command runs first