Maximizing Your Efficiency in Sublime Text - Plug-ins
Another feature that makes Sublime Text a little easier to work with is Plug-ins. Like all plug-in systems, Sublime Text’s Plug-in system allow for developers to extend Sublime Text’s functionality without having to submit a pull request or bloat the core. There are a huge number of plug-ins to pick from but I’m going focus on several that I’ve found to be very helpful in my PHP development.
Installation
Normally, to install a plug-in you would download the plug-in from the Internet then move it into “~/Library/Application Support/Sublime Text 3/Packages/User” on OSX and “%USERPROFILE%\AppData\Roaming\Sublime Text 3\Packages\User” on Windows. This process is so annoying I’m not even going to include a detailed explanation of how to do it because there’s a much better way.
Package Control
Package Control makes it easier to install plug-ins but Installing Package Control is a little complicated:
Installing
- Browse to https://packagecontrol.io/installation
- Copy the code section found under the “Sublime Text 3” tab (or whatever your current version is)
- In Sublime Text, use ‘ctrl + `’ to open the Console
- Paste into the text area and hit enter.
You now have Package Control installed!
New Menu Item
Now that we’ve successfully installed Package Control we can look at a new menu item it created.
The option is found under Sublime Text > Preferences > Package Control. Selecting this option will show the following command pallet:
This screen can also be accessed using command+shift+p and then typing “Package Control:”. There are three options that we’re going to talk about in this article.
Install Package
The “Install Package” allows you to install a package (duh, right) and after you select the option (after a short delay so the package list can be downloaded) you’ll be presented with a list of available packages. All you need to do to start the installation is select the package from the list.
Discover Packages
The “Discover Packages” option sends you to the package control website. This is helpful if you just want to browse other packages you might not know exist or you need something but you’re not sure what it’s called.
List Packages
The “List Packages” option displays the packages you currently have installed. Clicking on one of the items will bring you to the directory where the packages are installed in case you want to remove something (I’m not recommending that it’s just an option…). You can also you use the “Remove Package” option to remove them safely.
Installing a Package
The process for installing a package is as follows:
- command+shift+P or ctrl+shift+P
- Type “Package Control: Install Package” (you can copy and paste what I just typed or “Install” should work as well)
- After a couple seconds a list of packages will be listed. Type the name of the package you want to install and it will filter the search to just those elements.
- Select the package you want and click it (or arrow key down and press enter)
After a little while the package will be installed and you can start using it. The status bar will display what is going on during the process.
GitGutter
The GitGutter package uses Git to determine what changes have occurred in a file you’re working on by displaying indicators in the gutter of the editor window.
You’ll figure this out quickly after you start using it for a while but it shows:
Additions:
Deletions:
Changes:
For some reason additions will get grouped in with changes but I’m guessing that’s an “issue” with Git and not the plug-in.
I find this useful because I can easily see what parts of a file I’ve worked on regardless of if I’ve closed the file or not. It also helps me tell when I haven’t commited recently and if really need to.
All Autocomplete
Normally, Sublime Text attempts to autocomplete what you’re typing based on the currently open file. The All Autocomplete plug-in extends this to all the open files. I’ve found this to be very helpful because I usually need to open the file the function is defined in to double check it’s the correct function before I add it.
In the screenshot you can see I started to type getChildren and it found a match in FamilyController.php. Hitting tab will autocomplete the value like normal.
PHPCS
The PHPCS package allows you to automatically run the PHPCS tool (and a couple others) to make sure your code is up to snuff. If you’re developing using a standard this shows what’s wrong by highlighting the lines that have errors:
Placing your cursor on the error will show you what’s wrong:
PHP-Twig
As someone who dabbles in Symfony development from time to time the PHP-Twig Plug-in helps because it adds support for the Twig Template engine in Sublime. It mostly add syntax highlighting and autocompletion but just those really speed up my development.
PHPUnit Autocomplete
This is recent addition to my Sublime Text plug-ins (I found while researching this article actually) and it adds the PHPUnit functions to your autocomplete prompt. It’s nice when you forget the assert you’re looking for. :-)
SASS
The final plug-in I’m going to discuss is the SASS plug-in which adds syntax highlighting for SASS. I’ve pushed to get all my projects running on SASS and having the syntax highlighting for the files makes it easier to work with.
Conclusion
This just a brief overview of the different plug-ins that are available. I’ve had more plug-ins installed before but I try to keep the total low to keep everything running smoothly (although even when I had a bunch it was never a problem :-)).
I recommend you spend some time looking through the list of plug-ins on https://packagecontrol.io because you’ll probably find something useful for the way you work.
Scott Keck-Warren
Scott is the Director of Technology at WeCare Connect where he strives to provide solutions for his customers needs. He's the father of two and can be found most weekends working on projects around the house with his loving partner.
Top Posts
- Working With Soft Deletes in Laravel (By Example)
- Fixing CMake was unable to find a build program corresponding to "Unix Makefiles"
- Upgrading to Laravel 8.x
- Get The Count of the Number of Users in an AD Group
- Multiple Vagrant VMs in One Vagrantfile
- Fixing the "this is larger than GitHub's recommended maximum file size of 50.00 MB" error
- Changing the Directory Vagrant Stores the VMs In
- Accepting Android SDK Licenses From The OSX Command Line
- Fixing the 'Target class [config] does not exist' Error
- Using Rectangle to Manage MacOS Windows