Integrating Your Development Workflow Into Sublime With Build Systems - Part 1: Basic Build Systems

Sublime Text is a lightweight, but capable code editor that is greatly loved by many developers, but if you’re anything like me, you’re saddened a bit by the fact that Sublime doesn’t have an integrated system console. For many tasks that you use in the console, Sublime Text actually has a decent alternative: build systems. They allow you to run any console commands straight from Sublime. In this series I’ll be giving you the low-down on how to use Sublime’s build systems to their greatest potential.


Part 1: Basic Build Systems


Hey there folks! I’m Joe Zim and I’m here to talk to you a bit about making your life a little bit simpler by integrating your projects’ development work flow into your favorite code editor: Sublime Text. Without integrating your workflow into your editor, you’ll end up doing what I used to do: constantly switching back and forth between my editor and my console in order to run my commands for builds and such. I kept exploring ways to integrate a console into Sublime Text, but none of them worked to my satisfaction.

Sublime does have a built-in console, but it may not be exactly what you’d expect. It’s more of a Python REPL. As you can see, normal console commands don’t work, but python code runs, and you can run Sublime-specific commands from in here, but that doesn’t really help me at all. However, I did finally find a solution that I am satisfied with and it’s built right into Sublime: build systems.

You can find all the build systems that come with Sublime and the ones you’ve created under Tools > Build System. This is where you select a build system to use, but right now, we’re actually going to create a new one.

Click the New Build System menu item and it’ll open up a new file with the most basic bits. You may see shell_cmd or just cmd. There are some differences between the two, but I’ve always found shell_cmd does what I want and seems to be easier to work with, so I don’t really know much about cmd. If you’re more curious about it than I am, you can look at the documentation linked to below the video to find out more.

Let’s change this make command to ls as a simple example of a command that we can use in our build systems to see how they work. Then we’ll save the build system. Notice that it automatically takes you to the user packages folder for your Sublime Text installation, which is where you want to save these so that Sublime can find them. We’ll save the file as ls.sublime-build, and then Sublime will use the file name as the name of the build system.

If we go to the Tools menu and look at Build Systems, we’ll see our new build system is now listed there. Sweet! Let’s select it as our current build system…

Now we need to tell Sublime to actually run the build. You’ll notice that I’m using the mouse and the menus instead of keyboard shortcuts. This is entirely for your sake, so you can see what I’m doing. If you’re a keyboard user, you can always look at the menus to figure out the keyboard shortcuts for yourself, or customize them to your liking with the Key Binding preferences. Returning from our tiny tangent, though, let’s run this build.

And there you have it! We ran a shell command without leaving Sublime and the output showed up in a panel at the bottom of the screen. You may have noticed that we never specified which directory this command should be run in, but it listed the contents of the User Packages directory. In part 2 of these videos, I’ll show you some more options we can give to the build system so we can make these build systems a little bit more useful!


This isn’t the end of these tutorials. This is only part 1 of 4. I’ll be releasing these articles one day at a time, but all of the videos are already available on Youtube. Feel free to click through the annotations or cards to make your way through the series, or just work your way through the playlist. God bless and happy coding!

Author: Joe Zimmerman

Author: Joe Zimmerman Joe Zimmerman has been doing web development ever since he found an HTML book on his dad's shelf when he was 12. Since then, JavaScript has grown in popularity and he has become passionate about it. He also loves to teach others though his blog and other popular blogs. When he's not writing code, he's spending time with his wife and children and leading them in God's Word.