Sublime Text is a cross-platform text and source code editor written by Jon Skinner. One of its features is customizable build systems, allowing for the processing of files through external programs such as compilers, interpreters, and formatters, without leaving the editor.
Build systems let you run your files through external programs without leaving Sublime Text, and see the output they generate.
Build systems configurations are stored in .sublime-build
files. These JSON files can contain various keys:
selector
: allows Sublime Text to find the build, looking for the current file extensiontarget
: Sublime Text command to run (by defaultexec
)variants
: allows you to provide build optionswindows
: OS-specific configurationlinux
: OS-specific configurationosx
: OS-specific configurationcmd
: the command to execute when F7 is pressedfile_regex
: Perl regex to capture output ofcmd
line_regex
: Perl regex to capture output ofcmd
working_dir
: directory to change the current directory before runningcmd
encoding
: output encoding ofcmd
env
: dictionary of environment variables to be merged before passing them tocmd
shell
: if true,cmd
will be run through the shellpath
: will replace the current process' PATH before callingcmd
syntax
: output syntax for highlighting purpose
Here is a simple build, used to run the sass
command for .scss
and .sass
files:
{
"cmd": [
"sass",
"--update",
"--stop-on-error",
"--no-cache",
"--load-path", "${file_path}",
"--sourcemap=none",
"$file:../${file_base_name}.css"
],
"selector": "source.sass, source.scss",
"line_regex": "Line ([0-9]+):",
"osx": {
"path": "/usr/local/bin:$PATH"
},
"windows": {
"shell": "true"
}
}