Multiple actions per key binding


Quick and probably trivial question to anyone who might know:

How can I bind multiple actions to the same key binding, ensuring both get executed when the event is triggered?
I’m looking to enhance the traditional shift-delete key binding which should both copy and delete at the same time.
Currently it only deletes.

Is it as simple as adding two key mappings like this?

   'shift-delete': 'core:copy'
   'shift-delete': 'core:delete'


Isn’t this core:cut?

But to attempt to answer your question, no, there is currently no way to simply compose commands like you’re suggesting in Atom. I wish I could find the Issue where this exact idea was discussed. I think it was @izuzak that responded to it. Perhaps he can find his answer and link it for us here?


core:cut, ey?
I notice I don’t actually know where to find the reference for available commands.

I suppose a work-around would be to create a custom command via a package, but if core:cut does it in this simple case, that’ll be fine for now.


Well, the canonical list is the Command Palette. All commands that have been registered with the WorkspaceView (if I remember correctly, it is late … and yet, I’m still at the keyboard :smirk:) are available in the Command Palette and there is a simple translation between the command text and the text that shows up in the Command Palette, roughly:

  1. Replace hyphens - with spaces
  2. Place a space after the colon
  3. Capitalize the first letter of every word

So the command core:move-to-bottom becomes “Core: Move To Bottom” in the Command Palette. You can reverse the process to find the command that belongs to a Command Palette entry.


Ah ok, that rings a bell. Thanks for your quick though late response, @leedohm.
Better get some rest then!


Yeah, as far as I know – there’s no general way to do composition of commands if you want “composition” to mean “trigger A, wait for A to completely finish, then trigger B”. I think this is the thread that @leedohm remembers:, and my comment


I have submitted a PR for the shift-delete behavior now.


Did something on this topic change in the meantime? I would as well be really interested in this.

As an example, I don’t like that I have to use two commands / keybindings to reveal the currently opened file in the tree view. This should be possible by one command. I understand that I first have to change the active pane from the editor to the tree view, which (the three view) has the method to reveal the file. Somehow the tree view knows which file is currently open in the editor, so why can’t the editor has some kind of delegate to the tree view, to which you can send messages (like focus on yourself and reveal the current file).

Or maybe the keybindings (or Atom itself, after executing commands) can have a callback function, which you then can use a .then on?

Renaming a file is another example.


There are always going to be composite commands that people want. Rather than try to create a command for every possible combination of commands that people would want just so that they can be mapped to a key, there are ways to create your own composite commands. Check my StackOverflow answer for the way I think is best:


Thanks a lot for the link/post @leedohm . I’m currently trying to do something similar, I wrote it as a question on SO: