Last Updated: March 03, 2016
·
717
· mdeiters

Overriding a Default ATOM Keybinding

I like to run my tests/specs straight from my editor using. I've installed the ruby-test package and wanted to define my own keybindings like so:

cmd-r # runs the test file currently viewing
cmd-p # re-runs the last test I executed.
cmd-shift-r #runs the spec/test my cursor is on in the viewable test file

I ran into issues because cmd-r and cmd-p are already defined and used by Atom. To override them I have to redefine them first using unset!. My keymap now looks like this:

'.platform-darwin':
  'cmd-p':       'unset!'

'.platform-darwin atom-text-editor':
  'cmd-r':       'unset!'

'.platform-darwin atom-text-editor':
  'cmd-r':       'ruby-test:test-file'
  'cmd-p':       'ruby-test:test-previous'
  'cmd-shift-r': 'ruby-test:test-single'