How to execute command without entering palette?


#1

So i have added a command to my init.cofee

atom.commands.add 'atom-workspace', 'custom:colonize', ->
  editor = atom.workspace.getActiveTextEditor()
  editor.moveToEndOfLine()
  editor.insertText(";\n")

And added to keymap.cson

'atom-text-editor':
  'shift-enter': 'custom:colonize'

but i will like to execute it without having to enter the command palette.


#2

You don’t have to enter the command palette to execute the command if you’ve mapped the key binding correctly. Have you tried using the Keybinding Resolver (Cmd+. on OS X and Ctrl+. on other platforms)? It will show you what key Atom saw you press and the command that was triggered because of it.


#3

Yes, it executes first

editor:newline

and my command is the second on the list but does not executes.


#4

Here’s what I see when I press Shift+Enter:

Notice the selector on the editor:newline command? It is much more specific than the atom-text-editor selector you show in your example. Atom keybindings use CSS selectors and are therefore governed by specificity rules. See the Flight Manual for more details:

http://flight-manual.atom.io/behind-atom/sections/keymaps-in-depth/#specificity-and-cascade-order