Sublime Forum

Can't execute my plugin using a key binding


I just created a simple plugin and would like to add a keyboard shortcut to run it. I created a Default.sublime-keymap file in my Packages/User/ directory. The contents of that file:

        "keys": ["ctrl+shift+l"],
        "command": "add_line_numbers"

I saved all of my files and even restarted ST but when I press my keyboard shortcut I see a “no command for selector: noop” message in the console. The class name for my plugin is:

class AddLineNumbersCommand(sublime_plugin.TextCommand)



Perhaps the problem is not with the command name, but the keybinding. Maybe ST isn’t picking up those key combinations for some reason. You can always try running it from the ST console (View menu - Show Console), then view.run_command('add_line_numbers') Enter. If that works, we can debug the key press with sublime.log_input(True)

1 Like


If Default.sublime-keymap is loaded and the OS specific version (e.g. Default (Windows).sublime-keymap) is layered on top of it, then it’s possible that there is a binding that’s trying to disable the command in the platform specific bindings, which is clobbering that one.

In addition to what Keith mentioned, I would also try moving the binding to the appropriate platform specific file and see if the result changes.



Hey, I love your videos!

Where should “the appropriate platform-specific file” live in macOS?

The docs (at the bottom) state, “Users can customize their key bindings by creating a file named Default.sublime-keymap in their Packages/User/ directory.”

I created ~/Library/Application Support/Sublime Text/Packages/User/Default (OSX)sublime-keymap. Thank you for your help!!

1 Like


Interesting; there is a hierarchy to the key bindings, the file without the platform in the name is loaded first, and then the one for the appropriate platform (in this case OSX) is loaded on top.

The idea there is that there might be some bindings that are globally available regardless of OS, but you might want to change one of them only for a single platform.

For that reason, Preferences > Key Bindings (or for MacOS, Sublime Text > Preferences > Key Bindings) will open a split window for you to add your own customizations, and it will automatically create the appropriate file for you to put your bindings in.

Glad you got stuff all sorted!

1 Like