How to map a package's command to keymap?


How do I find out the exact name of a command in a package so that I can add it to my keymap?

For example, I have the SFTP Deployment package and would like to map “upload open files” to a key command.


If you can find the command in the Command Palette, then you can easily transform the Command Palette format to command format by:

  1. Change everything to lowercase
  2. Remove the space after the colon
  3. Convert other spaces to hyphens

For example:

  • “Foo Bar: Baz Quux” becomes foo-bar:baz-quux

Custom context menu without creating a package

Do these still go under .editor?

Because the 2 new ones I just added don’t work…

   'alt-enter': 'editor:insert-br'
   'alt-space': 'editor:insert-nbsp'
   'ctrl-u': 'sftpdeployment:uploadcurrentfile'
   'ctrl-alt-u': 'sftpdeployment:uploadopenfiles'


It looks like you missed Step 3: Convert other spaces to hyphens.


Doh! Indeed I did, sorry


Still no love, though:

   'alt-enter': 'editor:insert-br'
   'alt-space': 'editor:insert-nbsp'
   'ctrl-u': 'sftp-deployment:uploadcurrentfile'
   'ctrl-alt-u': 'sftp-deployment:uploadopenfiles'

where the commands are listed as such:


It looks like they’re not following the standard. Try the following: sftp-deployment:uploadCurrentFile

Step 2 should probably be, “Convert first characters in words to lower case”.


That was it.

I assume they should have have spaces in their commands, in which case your original instructions would have worked? And since they used Camel Case, I need to use it too?


Yes, that’s correct.


To find out what commands a package uses:

  1. Open Atom Package Settings View, find package from left sidebar, see “Keybindings” section.
  2. Take a look at the packages keymaps/package-name.cson file


That will work if they have mapped commands to keys already. But if they haven’t, then the simplest way to discover them without going code spelunking is to look at the Command Palette.

With this in mind, I’ve created atom/settings-view#165 to request an easier way to discover commands that do not come pre-configured with keybindings.


Here’s what you need:

  'ctrl-alt-u': 'sftp-deployment:uploadCurrentFile'

You need to have “atom-workspace” for the class. If you’re in doubt about what command to use, open up the preferences, click on Open Config Folder, open the “packages” folder, then the folder for the relevant package. Inside there, open the Menus folder, and click the file inside there. You’ll see all the commands used in any menus, either in the menu bar or in a contextual popup menu. Some packages don’t have any preset keybindings, so looking for a Keybindings folder won’t help you.