Search code examples
sublimetext2sublimetext3sublimetextsublime-build

Sublime Build variants hotkey


I am running a sublime build system to build my code.

I have 4 variants of the build system, and I want to map the first variant to a hotkey.

Right now I have the command "Build" mapped to F5. But when I hit it, it says...

shell_cmd or cmd is required [cmd: None]

Is there a way to map a specific build system variant to a hotkey?

Here is my build system fyi

{

"variants": [

    {
        "name" : "ndk-build",
        "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
        "cmd": ["H:/Tools/SublimeBuild/sublime-ndk-build.bat"],
        "working_dir": "${project_path:${folder}}",            
    },

    {
        "name" : "ant-clean",
        "cmd": ["H:/Tools/SublimeBuild/sublime-ant.bat" , "clean"],
        "working_dir": "${project_path:${folder}}",
    },

    {
        "name" : "ant-install",
        "cmd": ["H:/Tools/SublimeBuild/sublime-ant.bat" ,  "debug" , "install"],
        "working_dir": "${project_path:${folder}}",
    },

    {
        "name" : "Release",
        "cmd": ["H:/Tools/Release.bat"],
        "working_dir": "${project_path:${folder}}/../build",
    }
]

}


Solution

  • Just add to your keymap:

    { "keys": ["ctrl+f5"], "command": "build", "args": { "variant": "ndk-build" } },
    

    Aside: you can add a command at the top level as the default command and still keep the variants.