Sublime Text WordPress Development Set Up Guide

Scroll this

It’s been over 18 months since I made the switch to Sublime Text as my editor of choice. It has a simple yet powerful user interface, plentiful customization options and loads of performance. Bonus, it’s available for Windows, Mac and Linux … crazy.

Sublime Text’s features alone make it a great candidate for WordPress development. However, much like WordPress, Sublime Text’s hidden power is unlocked when you combine it with 3rd party extensions called “packages”.

Installing Package Control

Package control is to Sublime Text as the plugin and theme repository is to WordPress.org. It is the engine that powers the installation and management of community packages.

Package Control is not natively included with Sublime Text, but like WordPress plugins, it is easy enough to install. To install Package Control simply follow the instructions as detailed on the official website.

My Favourite Packages

Below are my favourite and most recommended packages for WordPress theme and plugin development. Believe me, they’ll make life easier.

Package Installation

Package Control is driven by the Command Palette. To install a new package:

  1. Press ctrl + shift + p (Windows, Linux)
    or cmd + shift + p (Mac)
  2. In Command Pallete type “Install” and select “Package Control: Install Package”.
  3. Enter the name of the package to install, select it from the choices available in the autocomplete list.

Package List

SublimeLinter
An absolutely essential package for PHP development. It performs real time scanning on your code using PHP’s native lint mode (i.e. php -l ) and reports back if it finds any errors.

How much time will this save you? You’ll be able to find and correct common PHP errors such as missing semicolons or braces right inside your code editor.

SublimeLinter also includes support for other programming languages such as JavaScript and functions in the same way to PHP linter.

WordPress
An extremely helpful package for WordPress development. It provides autocomplete functionality for many of the thousand WordPress functions, hooks, constants and classes.

WordPress Developer Resources
This great package allows you to search the new WordPress Developer Resources (developer.wordpress.org) or WordPress Codex (legacy) directly from Sublime Text. The tools is accessed via a context menu (right click), tools menu or via the Command Palette.

DocBlockr
This gem of a package simplifies the process of creating and managing documentation for your code. DocBlockr supports both PHP and JavaScript and shows a completion list for all tags supported by PHPDoc, JSDoc and others.

Sass
The final package is only useful if you are using Sass in your theme or plugins. Sublime Text lacks native support for Sass (Syntactically Awesome Style Sheets), so you’ll definitely want to install this package for overall better Sass support.

Free Bonus Help

Here’s a couple great user preference settings that you’ll hopefully find as handy as I have.

Trim Whitespace Automatically

Another way to keep your code clean is to ensure it’s free of unnecessary and unwanted trailing whitespace. To do so, simply follow the steps below:

  1. Select “Preferences” from the main menu.
  2. Select “Settings – User” from the drop down menu.
  3. A JSON config file will open.
  4. Add the following to the end of the file before the closing curly brace.
    "trim_trailing_white_space_on_save": true

    Unnecessary trailing whitespace will now be automatically trimmed every time your file is saved.

Ensure Files End with an Empty Line

While not a requirement in the official WordPress PHP coding standards document, it is recommended by the PSR-2 Coding Style Guide that all PHP file MUST end with a single blank line.

To comply with this guideline, simply follow the steps below:

  1. Select “Preferences” from the main menu.
  2. Select “Settings – User” from the drop down menu.
  3. A JSON config file will open.
  4. Add the following to the end of the file before the closing curly brace.
    "ensure_newline_at_eof_on_save": true

    This will ensure that newlines are present at the end of your files each time they are saved.

Wrap Up

I’ve share my favourite Sublime Text packages with you. What are your favourite’s? Let me know by leaving a comment.

2 Comments

  1. Thanks Darryl! I have to check that out! The sublimelintner would be great for me! Do you know if there’s any Drupal developer packs?

Comments are closed.