Sublime Text 2: moving on from Textmate

After 4 years of loyal service from Textmate, it was time to an upgrade in order to improve my coding productivity.

The long waited Textmate 2 being converted to an open source project still at an alpha stage hasn't made it a tool of choice for me.

Luckily, my fellow developer @kin_hung has been using Sublime Text 2 for quite a while and has showed me a list of useful packages that could seriously increase my productivity. So the choice was made.

I have listed some cool packages I have installed so far, but I probably will add more later on as I discover them so it'll be worth keeping an eye on this article.

First, let's get a package installer

This will allow us to install (almost) any package from the Sublime command line which is a big time saver.

Follow the instructions on this page:

Or simply type the following in your Sublime console (Menu > View > Show Console):

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'

Package Control Installation

Django templates, model fields & form fields

It really eases up writing Django code, I'm so glad I don't need to write {% %} ever again!

Template examples

if > {% if %} {% endif %}
ifchanged > {% ifchanged %} {% endifchanged %}
ife > {% if %} {% else %} {% endif %}
ifelse > {% if %} {% else %} {% endif %}

Model field examples

memail > models.EmailField()
mfile > models.FileField()

Form field examples

fdate > forms.DateField()
fdatetime > forms.DateTime()

Djaneiro

HTML & CSS high speed coding

Zen coding is the most intuitive way I have seen to shortcut HTML. You can write a string like this:

div#page>div.logo+ul#navigation>li*5>a

... and it will generate this:

<ul id="navigation">
    <li><a></a></li>
    <li><a></a></li>
    <li><a></a></li>
    <li><a></a></li>
    <li><a></a></li>
</ul>

That's at least 30 seconds saved!

Zen coding

Jquery

A long list of jQuery shortcut that will save you plenty of time again.

$ > $('#select DOM Element')
.click > .click(${1:function(${2:event}) {${0:// Act on the event}\}});

jQuery

Tutorials

If you wish to dig deeper into Sublime Text 2, then I recommend reading this tutorial:

https://tutsplus.com/course/improve-workflow-in-sublime-text-2/

< / >