SublimeText 2, Rocks.

Sublime Text 2 replaced Textmate as my default editor (sorry TM, you were awesome while it lasted) over six months ago and I haven’t looked back.

The first thing to know about Sublime Text 2 is that its package control system is awesome and it really makes the editor what it is. After downloading and installing Sublime you need to install the package control system. To do that open the built in command line interface by hitting Ctrl + ` (Thats a back tick and its the key just below the esc key on most keyboards.) Then paste in the following command into the command prompt at the bottom of the screen and hit enter.

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 2 to finish installation'

Restart ST2 and now the fun begins. To install a package press command + shift + P and start typing “install”, hit enter when the highlight is on Package Control - Install Package and it will load a list of packages. You can begin typing again to search through the package list.

Here are my favorite packages and the way that I set up ST2 for Django / web development + SEO copywriting and everything else.

  • Git - Cause you have to use source control
  • Sidebar Enhancements - Adds a bunch of contextual menus for working with files, viewing them in Finder etc.
  • SublimeCodeIntel - excellent code completion and more
  • SublimeLinter - Helps you code better by highlighting errors and PEP8 compliance. If your old code suddenly has squares around every line its this bundle. Simply put the carrot on the line and it will show you the error at the bottom of the screen
  • Djaneiro - Support for Django templates and some Django snippets
  • Colorpicker - For picking colors
  • Less
  • jQuery
  • Hyperlink Helper - A port of the Textmate plugin for inserting links
  • Jimbly’s Sublime Clipboard History - cause sometimes you need that code you copied a while back

ST2 also supports many Textmate bundles, depending on how they are written so you can add your favorites into ST2 pretty easily.

Big thanks to this post by Kenneth for the following on Subl.

Subl

Sublime text has nice mate-esque commandline launcher called ‘subl’ hidden in its distribution. To make it available universally:

ln -s /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl

Once Installed, you can run it anywhere to open a fresh project/window:

subl .

You can have it launch instead of Textmate when you forget by:

alias mate='subl -w'

Next you’ll also probably want to change some preferences to your needs or style. To do this open ST2 Preferences > Settings - User (also open Settings - Default for reference). If there are any that you want to change simply copy them over from Default and put them into your User settings. This makes it easy to copy your preferences to new machines / installs of ST2.

You can add any Textmate color scheme by simply downloading it and putting it in the packages folder. To view the packages folder go to Preferences -> Browse Packages. I like to place any I add into the Packages/User folder and then to activate it you would go to Preferences -> Color Scheme -> User

Then its just a matter of learning shortcuts and you’ll be well on your way. The two big ones are Command + P (Mac) for the now famous Goto Anything fuzzy match search to go to files, lines, launch bundles etc. Its awesome! The other is Command + Shift + P which is the command pallet and gives you every command available to you. Most of the other shortcuts you’re used to coming from TextMate or other editors are there too.

Let me know your ST2 tricks in the comments. Cheers!

I have added two galleries of Sublime Text 2 color schemes and Sublime Text 2 themes. Hopefully they help someone find the right look for them.