Tips on Sublime Text 2 – your favorite code editor

Unless you’ve lived under a rock lately, I’m sure you’ve heard of Sublime Text 2 and most likely that’s your favorite code editor.

In the past I used some other code editors like Komodo Edit or Aptana Studio, but now I use Sublime Text 2 on a daily basis and I’m pretty happy with it. It’s lightweight, easy to use and has a modern UI look. But by far, the best feature is the ability to extend its functionality with plugins, a.k.a packages.

Sublime Text 2

Top things people love about Sublime

  • The Goto Anything ability (Ctrl+P) is a time saver as you can quickly jump between files. Also, the Command Pallete (Ctrl+Shift+P) is very useful when trying to switch file’s syntax for example or search/change preferences.
  • I do enjoy the Distraction Free Mode feature (Shift+F11) whenever I want to focus even more on writing code.
  • Sublime Text 2 it’s extremely customizable. That’s right, you can customize almost anything like menus, snippets and completions.
  • The community is awesome, there are a lot of free plugins in the wild, ready to fit your needs.
  • Great user interface with some great predefined color schemes. I am a big fan of the Monokai default.

Perfect Workflow in Sublime Text 2

If you want to dive into the world of Sublime Text 2, then you don’t want to miss this awesome free video course by Jeffrey Way. He’ll convince you that Sublime Text 2 is merely the best code editor available today. Warning, he’s quite convincing! :)

Package Control

First of all, you should install Sublime Package Control. It helps discovering, installing, updating and removing packages for Sublime Text 2. Alternatively, you’ll have to manually install the plugins you need.

Sublime packagesList of installed packages.

Here are some packages I’m currently using:

  • ColorPicker – A color picker right in your Sublime editor.
  • SublimeLinter – Contains linting tools for various coding languages.
  • Prefixr – No need to worry about browsers prefixing anymore.
  • LiveReload – Spare your F5 key a little more.

Emmet & Hayaku

Emmet (previously known as Zen Coding) is a web-developer’s toolkit that can greatly improve your HTML & CSS workflow. It’s available for multiple code editors, including Sublime Text 2 as well. Also, as mentioned in their docs, Emmet is developed and optimised for web-developers whose workflow depends on HTML/XML and CSS, but can be used with programming languages too.

If you are a Sublime Text 2 addicted and a fan of abbreviations then you may give Hayaku a try too. With Hayaku you don’t need to remember abbreviations and use cheatsheets. You can write just any way you like the abbreviations to be and Hayaku would try it’s best to guess what you need.

Custom ANT targets

Speaking of customization, I frequently use the ANT build system and running custom build targets directly from Sublime Text 2 is super useful.

Using the Command Pallete (Ctrl+Shift+P) you can easily run an ANT target just by typing its name.
Custom ANT targets

Here’s an example that contains two ANT build targets defined:

{
    "selector": "source.java",
    "working_dir": "${project_path}",
    "cmd": ["ant.bat"],

    "variants": [

        { "cmd": ["ant.bat", "clean"],
          "name": "Clean"
        },

        { "cmd": ["ant.bat", "deploy-text"],
          "name": "deployText"
        }
    ]
}

Conclusion

Don’t forget to browse the whole list of published packages. You’ll always find something useful there. My latest discovered package that I want to give it a try soon is Sublime SVN. Also, if you want an even cooler icon for Sublime, you have some options. Check this resource out!

Good luck with coding!

21 thoughts on “Tips on Sublime Text 2 – your favorite code editor

  1. “Unless you’ve lived under a rock lately, I’m sure you’ve heard of Sublime Text 2 and most likely that’s your favorite code editor.”

    How arogant is that introduction!

  2. Great Article! I recently started using Sublime Text 2 and I absolutely love it! Here is my Setup.

    Or:

    Plugins:
    Package Control *install first*
    Alignment – http://wbond.net/sublime_packages/alignment
    All Autocomplete – https://github.com/alienhard/SublimeAllAutocomplete
    Bracket Highlighter – Highlights the corresponding bracket.
    Coffee Script – Magic
    Color Picker – CMD + SHIFT + C brings up a HEX color picker.
    Emmet – Amazing Zen Coding type plugin https://github.com/sergeche/emmet-sublime
    Git – Setup Git configuration and you can push, pull, commit, etc from sublime!
    jQuery – Autocomplete and additions for jquery.
    jQuery Snippets Pack – Jquery snippets
    JsFormat – Helps format for javascript
    Placeholders – Some nice snippets…. like “lorem” TAB inserts lorem filler text.
    PlainTasks – A cool tasks management. https://github.com/aziz/PlainTasks
    Prefix – Write out some css code and use CMD + CTRL + X to automatically generate the same code with the appropriate browser prefixes and setup.
    SFTP – A great FTP and Folder Mapping to Remote plugin! I use it all the time.
    SideBarEnhancements – Adds more tools on right click in the sidebar.
    SublimeLinter – Error handling.
    Tag – Helps with autoclosing HTML Tags.
    Gist – Post/pull gists directly from sublime.
    LiveReload – reload file in browser when an edit happens and without reloading!

    Appearance:
    Theme – Soda(light)
    Color Scheme – idleFingers

  3. Sublime Text 2 in just awesomeness, sublime!
    Yeah, it’s my only code editor forever, i think so. I too make blogs posts about it on my blog, for the Spanish community :)

    how to create the image of Package control? I refer about the effect of the bottom.

  4. Sir,

    I have doubt that when we add more js files which has java script codes, and jquery codes in a document. will it affect the document view factor like loading time/kill pages error. if no mean tell me how to handle js files in a document. because i’ve struggled with such problems

  5. Thanks this is looks cool, am going to try it! Though I use Aptana and I like it pretty much so far! But no plugins, which I love to have!

  6. Hi Im a noob to Sublime Text 2. When trying to run code, I cant. Ive tried pressing ctrl + b (Windows). I have been looking for an answer to this but cant find one. Do I need a plugin to be able to runcode. Sorry if this question is considered silly but I would really appreciate an answer. Thanks :)

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>