Sublime Build Systems
Custom build systems for compiling and running code in Sublime
Creating Build System
# Create new build system
Tools > Build System > New Build System
# Basic structure
{
cmd: [command, $file], # command to run
selector: source.python, # file scope
working_dir: $file_path # run directory
}
Python Build System
{
cmd: [python, -u, $file],
file_regex: ^[ ]*File (..*?), line ([0-9]*),
selector: source.python,
windows: {
cmd: [python, -u, $file]
}
}
JavaScript/Node Build
{
cmd: [node, $file],
selector: source.js,
path: $PATH:/usr/local/bin,
variants: [
{
name: Run with npm,
cmd: [npm, start]
}
]
}
C++ Build System
{
cmd: [g++, $file, -o, ${file_path}/${file_base_name}],
file_regex: ^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$,
working_dir: ${file_path},
selector: source.c++,
variants: [{
name: Run,
cmd: [${file_path}/${file_base_name}]
}]
}
Build Variables
$file # full file path
$file_path # directory of file
$file_name # filename with extension
$file_base_name # filename without extension
$file_extension # file extension
$project_path # project directory
$packages # packages folder