Sublime Forum

User Key Bindings not working

#1

Hello all,

I’ve been trying to get key bindings working to run an external program with a custom keybinding, but the keybindings never work.

The key binding command I’m using is:


	{ "keys": "f9"], "cmd": "C:\\ado\\personal\\rundo.exe", "$file_path//$file_name"] }
]

I can confirm that the code works as I also tried setting this up under the build menu, and that worked fine. It’s just not as graceful of an implementation.

Thanks,
mp1118

0 Likes

#2

Run this in the python console:

sublime.log_input(True) sublime.log_commands(True)

This will show what keys ST2 receives (in case it doesn’t receive f9) and what command is being run (in case some other command is already bound to f9).

0 Likes

#3

[quote=“mp1118”]Hello all,

I’ve been trying to get key bindings working to run an external program with a custom keybinding, but the keybindings never work.

The key binding command I’m using is:


	{ "keys": "f9"], "cmd": "C:\\ado\\personal\\rundo.exe", "$file_path//$file_name"] }
]

I can confirm that the code works as I also tried setting this up under the build menu, and that worked fine. It’s just not as graceful of an implementation.

Thanks,
mp1118[/quote]

Keybindings run a ST2 “command” only, not a “cmd” which is actually a shell command.
You cannot mix build config with keybindings.

If you want to run a shell command, you can use the “build” command that trigger your build config:

{ "keys": "f7"], "command": "build" }

or directly use the “exec” command which is the command that is executed by build:

{ "keys": "ctrl+shift+y"], "command": "exec", "args": {"cmd": "C:\\ado\\personal\\rundo.exe", "$file_path//$file_name"]} }

The problem is that it doesn’t work as the $file_path and $file_name are not expanded (something missing IMHO)
So FWIK, if using build system doesn’t work for you, you must write your own plugin that call the exec command without unexpanded variables.

Good luck!

0 Likes