Build Systems in Sublime Text 3

Adnan Ahmed
Mar 29, 2018 · 3 min read

Sublime has highly customizable build systems that can add to your productivity if you learn how to use them to your advantage. You can define one for your project and whenever you are editing any file, you can run certain commands on the source file and see the output in the sublime console, without leaving the editor.

I mostly use IntelliJ for development but still find myself switching to sublime text time to time, depending upon the nature of the project. I mainly use sublime when I have to write some small script or a library, and when I use it I prefer to setup the build system to make it easier to test. In this post I am going to explain how to create one by creating an example build system for a hello-world php application. But the steps should be same for any language. So let’s get started.

The first thing that you are going to do is create a new build system. You can do that by going to below path

This will open a new file named untitiled.sublime-build. Update the file and put the below content

Now save this file with the name php.sublime-build. To give you some details about the file content;

  • cmd here means the command that we need to run with the arguments that we want to pass it
  • selector is an optional string used to locate the best builder to use for the current file scope. This is only relevant if Tools > Build System > Automatic is true
  • file_regex specifies the file pattern that our build is going to be working with.

After saving the file you can see the build system inside Tools > Build System. Now you can run any php file ending with php as specified above in the above snippet. Now let’s test our build system. Create a new php file and put the below content in it

Now let’s run this file that we have created. So select php from Tools > Build Systems and hit CMD + B if you are on Mac, CTRL + B if you are on windows or Linux. Once you run it, you will notice the output for the build in the console, as shown in the image below

Image for post
Image for post

In case you want to cancel a stuck build, you can do that by pressing CTRL + C if you are on Mac, or Ctrl + Break if you are on windows or linux.

You can use the same steps to create a build system for any language. For example, here is how the contents of the build file may look like for a Javascript application

Hope you enjoyed the article, you can learn more about the build systems in the Sublime Docs, if you have any comments or feedback, leave them down below and feel free to connect with me on twitter or say hi via email.

tajawal

tajawal tech blog

Adnan Ahmed

Written by

Lead engineer @ tradeling. Lover of all things web, ponderer of new tech, fanatic of simplicity, OSS enthusiast https://github.com/idnan https://adnanahmed.info

tajawal

tajawal

tajawal tech blog

Adnan Ahmed

Written by

Lead engineer @ tradeling. Lover of all things web, ponderer of new tech, fanatic of simplicity, OSS enthusiast https://github.com/idnan https://adnanahmed.info

tajawal

tajawal

tajawal tech blog

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store