Where is a complete list of commands?


#1

https://atom.io/docs/v0.115.0/customizing-atom says

You’ll want to know all the commands available to you. Open the Settings panel (cmd-,) and select the Keybindings tab. It will show you all the keybindings currently in use.

It acknowledges that we’ll want to know all the commands available to us, but then instead tells us all the keybindings available to us, which is a very different thing. If I knew all of the commands available, I could easily create new keybindings, but just knowing all existing keybindings doesn’t really help me to do that.

To give a concrete example of what I could do with such a list—I could add a working keybinding for inserting a tab character.

# Sometimes it's useful to be able to insert a literal tab character
'.editor':
  'ctrl-alt-tab': 'editor:tab'      # <---- non-working pseudo-code

Without the list, I’m not sure how to insert a literal tab. I can insert a newline (editor:newline) but not a tab.

There are hundreds of other things that I might want to bind to keys, but without a comprehensive list, or a way to get Atom to generate such a list, I don’t know of any way to find them out.


Atom methods
#2
  1. Have you tried The Command Palette?

  2. As I understand, it is not possible to assign keybindings to all commands. Only to these, that are listed on ‘keybindings’ page.

  3. If there are package commands that do not support keybindings, you can contribute by adding a Keymap File.


#3

As @muchweb stated, the full list of commands is in the Command Palette. On the other hand, it is possible to assign a keybinding to any command in the Command Palette. That said, there may be functionality in Atom or packages that is not exposed via a command … at which point, you cannot assign a keybinding to it.

To sum up:

  1. If there is a command for it, it is in the Command Palette
  2. If there is a command for it, you can assign a keybinding to it (and the Keybindings page in Settings is one way to determine that mapping)
  3. Just because Atom or a package can do it, doesn’t mean there’s a command attached to it

You can create commands of your own, though.


#4

Been looking for the answer to this myself. If you open a console and type atom.commands.registeredCommands it will shows a complete list of all available command identifiers. Or at least I think that’s all of them. : )


#5

Since that’s not a confirmed public API, it might go away or its interface may change in the future etc etc etc


#6

That’s not totally accurate, only commands available from the current context appears in the command palette.

By context I mean the DOM element that currently have the focus. For instance, if you place the focus in an editor, the command palette will display every commands that you can trigger from here, which includes global commands (registered on atom-workspace) and editor’s commands (registered on atom-text-editor).

Now, place the focus on the tree view and the editor’s commands will no longer appear in the command palette.

As for keybindings it’s a little more subtle, you can register keybindings even if the command it targets doesn’t exist. Keybinding are just a way to tell Atom to trigger a command from a given context (through the keymap selector), so on the corresponding keystroke it’ll look at a command with the same name and with a selector that matches the current focused element.

Let’s take an example:

In my keymap.cson file I put this:

'.tree-view':
  'ctrl-shift-p': 'foo'

And my init.coffee I put that:

atom.commands.add '.tree-view', 'foo': -> console.log 'foo'

If I click on a directory in the tree view to give it the focus (clicking on a file will open an editor and put the focus in it) and open the palette command the foo command will be displayed with its keybinding. If I focus the editor, the foo command no longer appears in the command palette.

Now, about the keybindings view in the settings panel, it displays every registered keybinding, but that doesn’t mean there’s a corresponding command. In the example above, if I omit to define the foo command, the keybinding for foo will still appear in the settings.

In that, the documentation is somehow misleading because the settings view won’t show you commands that aren’t bound to a keybinding, but it will show you orphan keybindings. So you can’t rely on it to know the available commands, only the available keybindings.

Now, to list every commands registered in Atom it gets more complicated.
As mentionned by @leedohm, registeredCommands isn’t a confirmed public API, neither is selectorBasedListenersByCommandName.
The problem with registeredCommands is that it’ll only tell you that there’s a command with this name available somewhere, but it won’t tell you how you can trigger it. So it doesn’t help if the goal is to attach a keybinding to that command.
selectorBasedListenersByCommandName is much more accurate as it references the selectors in which a given command applies. But you can have several selectors for a single command with very different implementations depending on the scope where it applies (like core:move-up command).


#7

I have the same question “where is a complete list of commands?”.
Unfortunately all the answers above are not satisfying.

I can also confirm that not all commands are listed in the Command Palette.


#8

The list in Command Palette depends on where you open it.

  • Editor: commands are only displayed if you open the Palette from a text editor.
  • Some Tree View: commands only in tree view.
  • Some Markdown Preview: commands in markdown previews, etc.

#9

To open list of all editor commands, press shift-cmd-P. Then you HOVER over the command to see its name.


#10

I am having hard time knowing which context the keybinding works in. For example when working in the editor two keybindings need different context:

'editor':
  'ctrl-alt-s': 'window:save-all'

'atom-text-editor':
  'shift-enter': 'editor:move-to-end-of-line'

How do you know which to use ‘editor’ or ‘atom-text-editor’ ?
Where is the complete list of contexts ?


#11

The “context” is a CSS selector as described in the Atom Flight Manual section Keymaps In-Depth. Because it is a CSS selector, an exhaustive list would be pointless (if not infinitely long). The majority of keybindings should either be bound to atom-text-editor (for when it applies to both code editor views and simple single-line entry fields), atom-workspace (for things that should work anywhere such as Cmd+S) or atom-text-editor:not([mini]) (for things that should only work inside a code editor).


#12

I’ve been trying to find a command name, and found a few threads on here but no real answers. (I also tried the command palette, and found the item, but not the name. Currently hovering doesn’t seem to reveal the command name.)

I searched atom’s repo on github to find the source .cson. This is probably really silly but it did eventually work out for me. So if you really, really want a keyboard shortcut to save with whitespace or whatever silly menu item, it’s definitely buried in the source somewhere :slight_smile:


#13

If the hover text doesn’t appear for you, something else may be amiss. It definitely still works for me.


#14

The command is just the displayed name but lowercased and dasherized in more than 99% of cases. It wasn’t until very recently that the display name can be changed to be different from the command.


#15

yup. nice. no harm in just trying this first. works pretty much every time.
So Packages > Whitespace > Remove Trailing Whitespace is just whitespace:remove-trailing-whitespace.