Sublime Text is able to run build programs such as 'make', either when a key in pressed (F7 by default), or when a file is saved.
The build system to use can be select from the Tools/Build System menu. If a project is open, the selected build system will be remembered for the project.
The contents of the Tools/Build System menu is found by enumerating all of the .sublime-build files under the packages directory, which can be accessed via Preferences/Browse Packages. .sublime-build files are a simple key-value, text based format. A simple example is:
build make
lineNumberRegex ^(...*?):([0-9]*):?([0-9]*)
showWhenFinished true
workingDir $ProjectDir
There are four keys of interested here: 'build', 'lineNumberRegex', 'showWhenFinished', 'workingDir'. The meaning of these is:
[Finished in 1.029 seconds]
will be appended to the build output. If not specified, it defaults to true.Another, even simpler example:
build "C:\Program Files\SomeApp\SomeApp.exe" "$File"
This will launch SomeApp.exe with the current file as a command line argument.
In the above examples, you may have noticed a few variables being used: $ProjectDir in the first example, and $File in the second. The full list of these is:
C:\Files\Chapter1.txt
C:\Files
Chapter1.txt
txt
Document
C:\Files
Book
for C:\Files\Book.sublime-project
Snippet style formatting can be used with these variables, for example:
${ProjectName:Default}
This will emit the name of the current project if there is one, otherwise Default
.
${File/\.php/\.txt/}
This will emit the name of the current file, replacing .php
with .txt
.
After pressing F7, you can see the command that was actually run by taking a look in the Console (via View/Console).
If you're getting an error like 'make' is not recognized as an internal or external command, operable program or batch file
, try running same command in a command prompt and ensuring it works there.