In our last Sublime article we checked out several extensions for Sublime Text 3 that we use with development on a daily basis. This time around we’ll be looking at Sublime themes and color schemes along with a few additional tools that will help you save valuable seconds. If you haven’t already don’t forget to check out the first part of this article that will help you get familiar with Sublime Text, its extensions and how to install here.
Sublime Text Code Snippets
Among the many types of extensions there are for Sublime Text, some of the best for saving time are code snippets. These plugins serve a useful purpose if you’re relying on similar code blocks across multiple files or your code depends on API specification that’s easy to predict such as connecting to a Joomla database; there’s always the same schema: You need to initialize the Joomla! database object, create a query, set the query and get the results. With code snippets, you can instantly load up a block of code just for this purpose. Of course, the code’s not going to be exactly the same every time, but making a few minor changes is a lot easier than typing the whole thing out! Below we’ll show you how you can speed up your Joomla and WordPress development with few handy code snippets extensions.
Snippet Bundle for Joomla! 2.5
Don’t worry about the name. Yes we all know that Joomla! 2.5 is an old version that really should be avoided for new projects, but most parts of code are very similar to Joomla! 3 so this tool can still be useful when working with the latest Joomla build. This snippets package contains a lot of useful code snippets to use when developing templates, modules, plugins or components with Joomla. You can generate part of an XML manifest file, connect to a database or render every single Joomla! form field without checking the documentation.
Access to snippets it very easy – we use a simple shortcut to open the Command Pallete; ⌘/CMD + SHIFT + P. Then you just need to type the name of the snippet you wish to use. Don’t worry; all their names starts with Snippet: and then the name prefixed with the ‘j’ character, like Snippet: jaddbutton which will add this line of code to your document:
<?php echo ProductsHelper::button('hello', 'hello.png', JText::_('COM_PRODUCTS_QUICKICON_HELLO')); ?>
To install a snippets package we need to learn something new, namely how to add a repository where we can look for extensions. Of course it is very easy with the Commands Pallete, so we start with ⌘/CMD + SHIFT + P and then choose option called Package Control: Add Repository. At the bottom of the Sublime Text window you should see a small field where you can paste a URL, paste this link to the GitHub repository to this field to add the repository. Now we’ve added repository we need to get the extension installed, so as always open the Command Pallete again and choose to Install Package, then just search for joomla and hit enter. With this add repository option we’re just specifying another place where Sublime Text can look for extensions beyond the default repo that is initialized after installation; this is remarkably useful for finding a more wide-ranging extension selection.
Sublime Text Bundle Snippets for CMS Joomla!
This snippet bundle is very similar to the previous one, but as well as some XML elements, PHP or HTML code it also contains some very useful SQL commands to insert data to Joomla tables, generate new tables or dump existing ones. Installation is exactly the same as with the previous extension, but the URL to the repository is different. This plugin is also available on the GitHub repository so the only thing that you need to change is the URL.
Other useful extensions and themes
Code snippets are certainly useful, but there are many other ways to improve your experience with Sublime Text, from information-gathering, code management and themes to provide a readable, understandable look and layout that fits your style, whether you’re developing for WordPress or Joomla.
Search WordPress Codex
As the name suggests, with this plugin you can easily Search the WordPress Codex or open the selected function in the WordPress Function Reference with just two clicks for instant access to all the knowledge you need. When you select a WordPress function name and want to check official documentation you can right click and select the ‘WordPress Function Reference’ option to get more info. This saves a few seconds every time you need to look at something in WP documentation; this might not seem like much, but when you consider how often you need to double-check this kind of thing those seconds will quickly add up. The extension is available via the official repository so you just look for the Search WordPress Codex extension name in the "install package command" listings. I’ve been using this tools for a long time but sometimes Sublime Text just can’t force my default browser to open the URL. If you notice similar problems try using this very similar tool; WordPress Developer Resources Sublime Text 2/3 Plugin. You can use both tools at the same time, even if they do exactly the same thing!
Have you ever wondered how many times you copy and paste a bit of every day? Sometimes it’s necessary to apply the same change to multiple files and there is no way to cut corners; you just have to keep pasting the change bit by bit in each file. Usually you find that you become a CTRL/⌘ + C and CTRL/⌘ + V master in short order, switching between windows and getting things in order, but it doesn’t help the tedium. Thankfully, there are several applications which can help you with this, such as Keyboard Maestro, which can store clipboard history. The issue here is that it doesn’t discriminate; all copied instances are stored so you end up with code mixed in with copied tweets, documentation and anything else you happened to copy during your day. With Sublime Text you can install an extension which will keep a limited list of your clipboard history but, importantly, only from the Sublime Text editor, which is much better than the standard clipboard when you work with code. Clipboard Manager provides an easily accessible context menu with your clipboard history available in any Sublime Text file. Installation is very simple and as you should remember from our previous article the best way is to use the Package Manager. All that you need to do is choose the Install package option and find Cliboard Manager on the extensions list.
This one is for OSX users only. If you work on OS X you probably know a little tool called Dash. In short, Dash is a application which gives you instant access to more than 150 APIs – you just select the APIs which you want to keep locally and then even without an internet connection you can still check something in the WordPress codex or official Joomla documentation. The best thing in Dash is integration with many great tools like Alfred, XCode or even System Terminal. One of these tools is of course Sublime Text, and with the DashDoc plugin you can search any part of your code in Dash. This solution is much better than dedicated plugins for Joomla or WordPress documentation because Dash can keep all API documentations in one place, so no matter what function you’re looking for – PHP code, WordPress or Joomla – DashDoc will open the selected text in the Dash documentation browser.
The plugin is available on the official repository so installation couldn’t be easier; just look for DashDoc via the Package Manager.
Color schemes and Themes
We’ve introduced you to a few Sublime Text extensions which makes development easier and faster, but that’s not all you can do. With the Sublime Text editor you can also easily change the editor theme and the way that code is highlighted. This code editor offers a very solution for customizing all your settings like fonts, colors, icons, tabs layout and much more, and since it’s wildly popular there are a great many themes ready to go.
This is my personal favorite. This theme has a color scheme and highlight background that just works for me. What’s more, it changes the icons for files so you can easily recognize .js, .css or .html files. This theme and color scheme supports many 3rd party plugins like the aforementioned linters or git. The install process is also very easy, but with themes as well as the basic installation step you also need to set a particular theme as the default; everything is described at the GitHub repository page.
This color scheme is very similar to cobalt but built with the well know Soda pallete. Installation is possible via Package Control, but we still need to modify user settings file to set Flatland as a default scheme. For more details please check out the Flatland official repository page.
This one contains two variants; dark and light. The light one is very similar to popular code editors like Coda or Espresso, so if you’ve worked with them before you’ll be right at home with this color scheme. This theme offers two variants of the tabs layout: Chrome style and the default layout, and also allows you to modify folder icons. More details about Soda theme and the installation steps you can find on the repository page.
And that’s it for this article! We hope that these tools and themes help keep your development running smoothly, and if you’ve got any extensions or themes you particularly like why not let us know about them in the comments below?
All images used in this post are courtesy of the respective Sublime Text theme developers; visit their github (links in article) for further information.