When you have the Build System set to Automatic (e.g. Tools > Build System > Automatic
from the menu), Sublime should select the correct build system for the currently focused file as long as the build file is set up correctly.
Based on the build system you have outlined above, as long as you have some package installed that is providing a custom syntax for this package (e.g. the q KBD package) that assigns the scope source.q
as a base scope, this should work fine in this case.
To verify, while a q
file has the input focus, select Tools > Developer > Show Scope Name
from the menu (or press the associated key) and make sure that the scope begins with source.q
(the package above does this). The scope that you see may be longer than this depending on where you are in the file, but as long as it starts with this, you should be OK.
If that's not the scope that you see, then the reason the build as you've outlined it is not automatically selected is because the package you're using uses a different scope, or you don't have a q
package installed (this is the case if the scope you see is text.plain
, for example).
The solution in that case would be to either update the scope based on the package you're using or install the above package (if you don't have anything related to this already installed).
In lieu of installing a support package that provides a syntax, you could also modify the build to be as follows, which should tell it it to use the build for all *.q
files regardless of their scope. Arguably the package install method is superior since it would give you syntax highlighting for your files as well.
{
"cmd": ["[full q path]", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"file_patterns": ["*.q"]
}