Sublime Forum

Change build system by keyboard shortcut

#1

Since I’m writing in two different dialects of markdown that do two very different things, I often times end up switching the build system back forth between the two. I was wondering if it would be possible to cycle through build systems or give build systems their own short cut.

1 Like

Build systems for files without extension
#2

There is a set_build_system command that you can use to set the current build system. With it you could create a couple of unique key bindings. For example, this one uses Ctrl+Alt+Shift+W to set the current build system to the one used to run Wren programs:

    {
        "keys": ["ctrl+shift+alt+w"],
        "command": "set_build_system",
        "args": {
            "file": "Packages/Wren/Wren.sublime-build"
        }
    }

In order to have one key binding that toggles between the two build systems I think you would need to create a plugin (assuming there isn’t already one) that kept track of which one it set last and set the next one. You can make a key binding contingent on a particular setting but I’m not sure if there is a context that covers build systems.

If the two dialects of Markdown are this different, are they covered by the same syntax? Build systems use syntax scopes to determine which build system to use, so perhaps there’s something different about the two that you could use to set things up so that the automatic build selection would just work for you?

2 Likes

#3

Thanks! That worked wonderfully.

1 Like

#4

There is an even better solution to this that makes use of the automatic build selection features, which are

  1. Only allowing to choose a build system if it is valid.
  2. The user can still change the build system at any time using the ctrl+shift+b key binding since automatic mode is still active.

Basically, it’s running the build command with options such as these:

"command": "build", {"args": {"build_system": "Packages/LaTeXTools/LaTeX.sublime-build", "variant": "", "choice_build_system": true, "choice_variant": true}
5 Likes

#5

Sweet, I didn’t know you could do that. I thought the only argument you could pass to the build command was a variant.

Filed away for future use!

0 Likes