Sublime 2 -- An awesome text editor / IDE

Author: 
Parent Feed: 

Everyone has their favorite text editors. For my first few years as a professional developer I used Textmate, not even realizing its more advanced features. When I started at OpenSourcery, peer pressure got me using Vim, which is actually great, since it's on 99% of the web servers I work with.

Just recently, however, I began using Sublime 2, which is actually more of an IDE, since it offers tons of advanced features and allows you to manage an entire project rather than managing just a single file at a time. This brings me to my first tip I use *all the time*:

command-p

(Linux users may need to use a different key like control.)
This brings up a list of files in the current project. Let's say you want to edit settings.php. Run this command then type "set" -- instantly, settings.php shows up at the top of the list. Hit enter and voila! You're editing settings.php.

command-shift-p

This brings up a list of available commands. Handy if you don't want to use the mouse, and it piggy-backs onto all the other add-ons you've installed, providing short-cuts to all sorts of commands.

Package Manager

This is my favorite part of Sublime, which is not actually part of the program out of the box. Like many Linux distributions out there have "package managers," Sublime has one too. Check it out!

command-k command-b

I think this is the first program I've seen that combines two keystrokes, but it's definitely useful. This will show or hide the sidebar that shows the project's file structure.

Vim Emulation

Sublime comes with a Vim emulation "vintage mode" out of the box. Just enable it! Here's some documentation. Mac users, pay attention to the "OS X Lion" section here. Key repeats are part of the "Vim experience," IMHO. Also, try out the VintageEx package.

Drupal auto-completion

Now that you have the package manager installed, type command-shift-p to bring up the list of commands, then type "pac" and the package manager commands will appear. Select "Package control: Install package". Let it work a bit, then start typing "Drupal" -- WOW! Sublime has a few packages just for Drupal development! Drupal Project Autocomplete is one.

Drupal code snippets

Like the previous tip, this is another package. Pretty great!

Goto Drupal API

Again, install this using the package manager. I don't use this command all that much, because of my Chrome search shortcuts, but it does work well and it's quick. Double-click a core function in any of your project files to select it, type shift-command-p to bring up the list of commands, then type "go" and hit enter. Your browser opens right to the documentation page at api.drupal.org! Awesome!

INI syntax highlighting

"INI" is yet another package useful to Drupal developers. Install it! Then, open any module's .info file. Next go to "View >> Syntax >> Open all with current extension as… >> INI"
This also works with .make files.

PO file syntax highlighting

command-d

This is one of the classics. I believe it's demonstrated on the Sublime 2 front page.

More…

Yes, there's much, much more. Some things I'm trying out, but haven't quite figured out include Ctags support, which provides the ability to click on a function and jump to where that function is defined. Also, an Xdebug interface is available, although I haven't quite gotten this configured yet. Next on the list is DrupalCS support, which should allow you to check the code in any given file against Drupal's coding standards.

If these short-cuts sound good to you, do yourself a favor and start out your free trial of Sublime 2, available for Mac, Linux and Windows! Test it out, and buy when you're ready!

Original Post: