Search code examples
qmlsublimetextsublimetext3build-system

Custom build system for QML in Sublime Text 3


I have created a build system for QML in sublime, so selecting that build system and doing a ctrl+B builds the qml code for me. But every time I switch between different type files (eg. a .py file and .qml file) I have to change the build system from QML to Automatic and vice versa. What can I do so that sublime automatically recognizes a .qml file and selects the appropriate build-system when Automatic is selected? (which for my .qml files should be the QML.sublime-build that I created)

Here is my build system for qml: (in the file "QML.sublime-build")

{
    "shell_cmd": "qmlscene.exe $file_name"
}

Solution

  • The documentation and reference for build systems contain all the information you need. Specifically to your situation, you need a "selector" option:

    {
        "cmd": ["qmlscene.exe", "$file_name"],
        "selector": "source.qml"
    }
    

    You can now select Automatic in the Build Systems menu, and hitting CtrlB will build QML files with this system, and Python files with the Python build system.