Sublime Text for Drupal - installation and configuration
Kommentare


Tony
4th Februar 2013 - 07:02
This editor rocks! Its super fast and am ditching my Aptana Eclipse for this.
Thanks for this useful info.

Rémy
21st April 2013 - 15:04
this is also very useful, BuildSystem for drupal coding standards:
https://github.com/sirkitree/DrupalCodingStandard

3
Welcome to the second part of my blog post series about Sublime Text 2.
In this post will explain how to configure Sublime Text for the needs of a Drupal developer.
Installation
It is very simple to install Sublime Text 2 (ST2). Just go to the Sublime Text Website, download the editor and install it like you'll do it with every other program.
Configuration
Now we are talking about the really exciting things in ST2. As mentioned in the previous blog post, out of the box the editor comes with some neat features like:
But ST2's real powers are unleashed through its plugin architecture. There are tons of high quality plugins and packages already available out there.
As a Drupal developer RJ. Pittman's (phase:II) script provides an automatic and hassle free setup for your developing needs. This means running the script won't require any other further configurations but for a better understanding I recommend reading my entire post.
At this point I also want to mention his blog post about this sophisticated editor.
Configuring the text editor
To meet the requirements of Drupal coding standards, we need to configure the text formatting (Please note that my shortcuts are refer to Mac OS X). To do so go to Sublime Text 2 - Preferences - Settings User ( cmd + ) and add the lines below.
{ "rulers": [80], "tab_size": 2, "translate_tabs_to_spaces": true, "use_tab_stops": true, "trim_automatic_white_space": true, "trim_trailing_white_space_on_save": true, "ensure_newline_at_eof_on_save": true, "fallback_encoding": "UTF-8", "default_line_ending": "unix", "shift_tab_unindent": true, "word_separators": "./\\()\"'-:,.;<>~!@#%^&*|+=[]{}`~?" }Save the file and restart ST2. (Source: Drupal.org)
Installing Package Control
Will Bond has created the very easy to install Package Control for ST2.
Start ST2 and go to View - Show console in the menubar (ctrl+`).
Copy and paste this command and hit the return key on your keyboard.
import urllib2,os; pf='Package Control.sublime-package'; ipp=sublime.installed_packages_path(); os.makedirs(ipp) if not os.path.exists(ipp) else None; urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler())); open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen('http://sublime.wbond.net/'+pf.replace(' ','%20')).read()); print 'Please restart Sublime Text to finish installation'If everything worked out, and you restarted your ST2, you should be able to use the package control to install new and awesome plugins for your editor.
Press command+shift+p on your keyboard to open the command palette and type install followed by the return key.
Now you can search all available packages/plugins just by start typing.
Type git and you'll get a list with all packages related to Git.
Select the package you want to install, in our case just Git and hit the return key.
The plugin is now being installed for you. In this case please note that you need to have Git installed locally in order for the plugin to work.
After the installation is finished you can open the command palette by pressing cmd + shift + p and type git for a list of all available commands.
It is also possible to just type pull, push or quick in the command palette to find the command you are searching for.
In my case I had troubles to get the plugin to work. Following error message appeared.
I had to adapt the git_command configuration in the Git.sublime-settings file.
Go to Sublime Text 2 - Preferences - Browse Packages in the menubar. Search for the Git folder and open the Git.sublime.settings file by double-clicking it.
Change the git_command value from true to the path your git executable is located.
If you don't know where your git executable is stored, just open a console and type which git and you'll get the answer. In my case it was /usr/local/git/bin.
Proposed packages to install
In the short time I have been using Sublime Text 2 I the following packages have proven their use to me. You can find the list in our Wiki.
The installation of these packages works in the same way as in my example of the Git package.
Conclusion
As you can see, Sublime Text 2 is not a fully featured editor from the beginning. But the power behind the scenes is tremendous and only limited by the imagination of the plugin-developers. I will keep my eyes open for new plugins that are useful together with Drupal development. If you know about a must-have plugin that I missed, let me know and I will check it out.
In the next part of this blog series about Sublime Text 2 I will write about the very useful keyboard commands.