What commands for keybindings?


#1

Hello.

Starting with a keybinding as an example:

'atom-text-editor':  # scope
  'ctrl-up': 'core:move-to-top'  # function
  'ctrl-down': 'core:move-to-bottom'

Where can I find all the different scopes that is available … and their spellings? In the above example I would have thought to use ‘TextEditor’ as described in the API.

Next - Which general functions are available in the core of Atom? I did not expect the ‘-’ in the name and also not the ‘core:’ description as prefix.

Thanks for your attention and consideration.

  • Dan

#2

The Flight Manual section on customizing keybindings uses atom-text-editor as an example. Scopes, in this case, are CSS selectors. A keybinding will be recognized when the element specified in the selector recognizes a key press event happening while it is in focus, so the best way to find the scope you should use is to use the developer tools to browse the DOM and find the element you want to target. For most people, all they need to know are '*' and 'atom-text-editor', to distinguish between keybindings that they want global and ones that they want to apply only when they’re writing code. Package developers might have additional needs, which is why there’s a more in-depth explanation in a later chapter.

Next - Which general functions are available in the core of Atom?

You can open the Command Palette (ctrl-shift-p) and type core: to see the list of all of them.

I did not expect the ‘-’ in the name

If you hover your cursor over an entry in the Command Palette, you can see a tooltip with the Atom-readable representation of its name. After a while, you stop thinking about it and your brain seamlessly translates between human-readable and Atom-readable.


#3

Hello.

:blush:(…good answer!)
Using the command pallet is a nice straightforward and simple answer.

Are all possible commands however listed therein? Are all the API functions listed in the command pallet?

For example - where is “select-up” and “select-down” for example?

Some commands that already has key-bindings, can be found by searching the key-binding registry (SETTINGS >> KEYBINDINGS) or the using keybinding resolver.

The above trick will work when looking to rebound functionality to other keys. Not all commands are in the command pallet.

Core Question:
----------------------
Is there perhaps a Javascript function or Atom API function that can be called in the Atom Console that expose the “public” commands / functions that are loaded into memory and can be executed?

  • Dan

Late note…
Perhaps in the Console execute dir(atom) or dir(window) or something like this?


#4

Thanks. :slight_smile:

Are all possible commands however listed therein?

Yes. It will index every command that has been added to Atom’s CommandRegistry.

Are all the API functions listed in the command pallet?

It’s “palette”, as in the board used by painters to hold all of their colors easily accessible. None of the API functions are listed there, because that is not its purpose.

For example - where is “select-up” and “select-down” for example?

When I open the Command Palette and type “select”, the first result is Core: Select Up.

The above trick will work when looking to rebound functionality to other keys. Not all commands are in the command pallet.

If you can verify that a command is in the registry and it isn’t appearing in the Command Palette, then that sounds like a bug.

Is there perhaps a Javascript function or Atom API function that can be called in the Atom Console that expose the “public” commands / functions that are loaded into memory and can be executed?

This sounds dangerous. The documented public API is a set of functions that aren’t going to change any time soon. While Atom does include functions that aren’t documented in the API, the devs don’t make any guarantee of those functions staying the same as Atom changes.


#5

:blush:
Earlier today I did not find “select” in the pallet… yet now I do. Perhaps I do need to see the eye doctor!?

I messed around with some coding even before I read your message.

  • Open up an empty document (text) in the editor.
  • Executed code in the Console
clear()
editor = atom.workspace.getActiveTextEditor();
group = atom.commands.registeredCommands
for(var b in group) {
  if(group.hasOwnProperty(b)) {
    editor.insertText(b);
    editor.insertText("\n");
  }
}

What I like about the above list is that the full command name as you would use it in the keybinding, is now in text file.

Also interesting results where:
group = atom … some sub divided groups to investigate later
group = window

  • Dan

#6

Some results:

application:add-project-folder
application:bring-all-windows-to-front
application:hide
application:hide-other-applications
application:install-update
application:minimize
application:new-file
application:new-window
application:open
application:open-dev
application:open-file
application:open-folder
application:open-license
application:open-safe
application:open-your-config
application:open-your-init-script
application:open-your-keymap
application:open-your-snippets
application:open-your-stylesheet
application:quit
application:show-preferences
application:show-settings
application:unhide-all-applications
application:zoom
bracket-matcher:close-tag
bracket-matcher:go-to-enclosing-bracket
bracket-matcher:go-to-matching-bracket
bracket-matcher:remove-brackets-from-selection
bracket-matcher:remove-matching-brackets
bracket-matcher:select-inside-brackets
core:backspace
core:close
core:copy
core:cut
core:delete
core:move-down
core:move-left
core:move-right
core:move-to-bottom
core:move-to-top
core:move-up
core:page-down
core:page-up
core:paste
core:redo
core:save
core:save-as
core:select-all
core:select-down
core:select-left
core:select-page-down
core:select-page-up
core:select-right
core:select-to-bottom
core:select-to-top
core:select-up
core:undo
editor:add-selection-above
editor:add-selection-below
editor:auto-indent
editor:checkout-head-revision
editor:consolidate-selections
editor:copy-path
editor:copy-project-path
editor:copy-selection
editor:cut-to-end-of-buffer-line
editor:cut-to-end-of-line
editor:delete-line
editor:delete-to-beginning-of-line
editor:delete-to-beginning-of-subword
editor:delete-to-beginning-of-word
editor:delete-to-end-of-line
editor:delete-to-end-of-subword
editor:delete-to-end-of-word
editor:delete-to-next-word-boundary
editor:delete-to-previous-word-boundary
editor:duplicate-lines
editor:fold-all
editor:fold-at-indent-level-1
editor:fold-at-indent-level-2
editor:fold-at-indent-level-3
editor:fold-at-indent-level-4
editor:fold-at-indent-level-5
editor:fold-at-indent-level-6
editor:fold-at-indent-level-7
editor:fold-at-indent-level-8
editor:fold-at-indent-level-9
editor:fold-current-row
editor:fold-selection
editor:indent
editor:indent-selected-rows
editor:join-lines
editor:log-cursor-scope
editor:lower-case
editor:move-line-down
editor:move-line-up
editor:move-selection-left
editor:move-selection-right
editor:move-to-beginning-of-line
editor:move-to-beginning-of-next-paragraph
editor:move-to-beginning-of-next-word
editor:move-to-beginning-of-previous-paragraph
editor:move-to-beginning-of-screen-line
editor:move-to-beginning-of-word
editor:move-to-end-of-line
editor:move-to-end-of-screen-line
editor:move-to-end-of-word
editor:move-to-first-character-of-line
editor:move-to-next-subword-boundary
editor:move-to-next-word-boundary
editor:move-to-previous-subword-boundary
editor:move-to-previous-word-boundary
editor:newline
editor:newline-above
editor:newline-below
editor:outdent-selected-rows
editor:scroll-to-cursor
editor:select-line
editor:select-to-beginning-of-line
editor:select-to-beginning-of-next-paragraph
editor:select-to-beginning-of-next-word
editor:select-to-beginning-of-previous-paragraph
editor:select-to-beginning-of-word
editor:select-to-end-of-line
editor:select-to-end-of-word
editor:select-to-first-character-of-line
editor:select-to-next-subword-boundary
editor:select-to-next-word-boundary
editor:select-to-previous-subword-boundary
editor:select-to-previous-word-boundary
editor:select-word
editor:split-selections-into-lines
editor:toggle-indent-guide
editor:toggle-line-comments
editor:toggle-line-numbers
editor:toggle-soft-tabs
editor:toggle-soft-wrap
editor:transpose
editor:unfold-all
editor:unfold-current-row
editor:upper-case
find-and-replace:clear-history
find-and-replace:find-all
find-and-replace:find-next
find-and-replace:find-next-selected
find-and-replace:find-previous
find-and-replace:find-previous-selected
find-and-replace:replace-all
find-and-replace:replace-next
find-and-replace:select-all
find-and-replace:select-next
find-and-replace:show
find-and-replace:show-replace
find-and-replace:toggle
find-and-replace:use-selection-as-find-pattern
window:close
window:copy-active-item-to-pane-above
window:copy-active-item-to-pane-below
window:copy-active-item-to-pane-on-left
window:copy-active-item-to-pane-on-right
window:decrease-font-size
window:focus-next-pane
window:focus-pane-above
window:focus-pane-below
window:focus-pane-on-left
window:focus-pane-on-right
window:focus-previous-pane
window:increase-font-size
window:log-deprecation-warnings
window:move-active-item-to-pane-above
window:move-active-item-to-pane-below
window:move-active-item-to-pane-on-left
window:move-active-item-to-pane-on-right
window:reload
window:reset-font-size
window:run-benchmarks
window:run-package-specs
window:save-all
window:toggle-auto-indent
window:toggle-bottom-dock
window:toggle-dev-tools
window:toggle-full-screen
window:toggle-invisibles
window:toggle-left-dock
window:toggle-menu-bar
window:toggle-right-dock