Those of you, who have been living under the rock and "Sublime Text" is alien, please refer the following blog posts:
How many times have your system got struck using various memory-sucking Heavy IDEs? I am sure most of us want to use a lot of features that an IDE could provide us. But at the same time, we think about how much of memory would it take to have this feature up and running. Will my system be able to sustain it or no?
Sublime text is a really light-weight editor which solves all these problems for us. I have tried various editors like eclipse/phpstorm/comodo and many more but the performance that I get with sublime is not comparable with them. Being a Drupal developer, my needs are pretty simple. The few things that I want my editor to do for me are:
- Easy Autocompletion for various API functions
- Easy way for Doxygen style commenting
- Ability to check for Coding standards
- Fast searching
If you have or are using any IDE right now for drupal development, you would have already started counting the plugins like Xdebug, Codesniffer and various other plugins that you would need to have these features up and running. Sublime makes it really simple to set these up with its extensive list of plugins and a simple plugin manager called as package manager. If you haven't yet installed package manager, i would suggest getting it setup (makes it really easy to install the plugins)
In this article lets go through the plugins that sublime offers for the first 3 basic features mentioned above:
Drupal Autocompletions/De-oxygen style Commenting
Drupal-sublimetext provides us with autocompletions, deoxygen style commenting for functions and snippets for drupal hook suggestions. Installing this is pretty simple.
Type ctrl+shift+p and type install. This will bring up a list of options. SelectPackage Control : Install Package. This will bring up a list of sublime plugins installable via package manager.
For Mac OS X;
Type in Drupal and press enter.
Ability to evaluate code against Drupal Coding Standards(Drupalcs)
copy DrupalCodingStandard.sublime-build into Packages/User directory. On Mac OS X, ~/Library/Application Support/Sublime Text 2/Packages/User
Now, you need to install PHP Code Sniffer which this plugin makes uses to evaluate your code. Follow the steps here to install phpcs and ad Drupalcs. To evaluate your code in sublime,
Select Tools > Build System > DrupalCodingStandard
Open a Drupal file and press
ctrl + B (on linux/windows)Orcmd + B (on Mac OS X)
Sublime makes it easy searching for functions across a project by using ctags. Install it using package control(Search for Ctags). To configure ctags on your machine,
Ctags doesn't know that .module and .inc files are php files to be indexed. To add these to mappings as well,
Now goto your project root folder and run ctags command.
Ctags can be updated from now on from sublime itself. Just right-click on the folder and click on Ctags: Rebuild Tags.
Thats all you need to do and now your sublime text 2 editor is powered up with tools making your development life much easier..:)Stay tuned for my next article explaining how to configure your dev machine to avoid checking in a piece of code thats not complaint with Coding standards/has some syntactical errors through GIT.