Sublime Text 2: A new IDE

I’ve recently been trying a new IDE and I’ve been so impressed I’ve decided to spread the love. Sublime Text 2 is cross platform (Windows, OS X, Linux) IDE, it claims to be a text editor but to refer to it as such is to do it an injustice, whilst it might not provide a fully integrated environment it is defiantly a developer tool rather than just a text editor.

NOTE: The views reflected in this post are solely my own and in no way reflect the views and opinions of the University of Kent. The University of Kent does not endorse any of the mentioned products.

NOTE: Apologies, I develop on OS X and therefore this review is from that perspective, if you are on Linux or Windows replace CMD shortcuts with CTRL and you should be fine.

Cost

Sublime is $59, more than TextMate ($44.85) but less than Coda ($99), and obviously significantly more than the many free options out there, Eclipse being the most obvious. However the trail is unlimited, you just need to dimiss a prompt to buy every so many saves. Personally I think Sublime is well worth the $59, however I’m going to put up with nagging until I see what Coda and TextMate have to offer in their upcoming V2s (if they ever come out).

Cool stuff

Hot exit

I’m not sure if this is cross platform or just tied into Lion’s resume API but its awesome, quit Sublime and the next time you open everything will be as you left it, including the scroll position (of the current file, would be nice if it was every file).

It will even keep any changes in unsaved files!

Mini map

I’m not sure how useful this feature is but it is cool, its basically a thumbnail’s width view of the current file on the right side of the window you can use to scroll the file.

Command menu, CMD+SHFT+P

This adds a little confusion as some commands are in this searchable menu and some are in the application menu and some are in both. But it works really well for when you can’t remember the shortcut for some thing (or there isn’t one).

Goto anything menu, CMD+P

This is possibly the single coolest feature:

Sublime Text 2 has Goto Anything (Ctrl+P on Windows and Linux,Command+P on OS X) to quickly navigate between and within files:

  • Type part of a file name to open it. Files can be open files, recently closed files, or files in the project. The fuzzy matching is fast and intelligent, providing instant-as-you-type navigation on 50,000+ file projects.
  • Type an ‘@’ character, and start browsing by symbol. Type ‘#’ to search within the file, or ‘:’ to go to a line number.
  • Combining these together, for example, “tp@rf” may take you to a function called “read_file” within a file named “text_parser.py”. Similarly, ‘tp:100′ would take you to line 100 of the same file.

The Goto Anything panel previews where it will take you as you type, loading files asynchronously in the background. You can use this to quickly look up the definition of a function, pressing escape to go back.

The various within-file symbols operate on the current file if typed alone, for example, “:50″ will take you to line 50 of the current file, and “@” will browse the symbols of the current file. There are key bindings to open the Goto Anything panel with these pre-filled, for example, Ctrl+R (Command+R on OS X) will go directly to the list of symbols in the current file.

Multiple select

You can insert your cursor at multiple points in your file, just hold down CMD and click to create a new cursor, if you CMD+drag you can create multiple selections, if you CMD+double click you can select multiple words. To create multiple cursors across multiple lines hold down CMD+ALT and drag your mouse across the lines you wish to place insert points at. Typing will then occur at each of the cursor points.

Snippets

These work exactly like in TextMate (in fact Sublime support TextMate tmSnippet files) however having not really used TextMate before I find these very cool, and much much better than Coda’s snippets. I found it takes a little editing of distributed snippets to get them insert code to match your personal preference but its defiantly worth it.

They work by pressing tab after certain tab trigger key words, for example if I type foreach and press tab in a php file I will get something like

foreach ($variable as $key => $value) {
	# code...
}

pressing tab will then move the selection through $variable, $key, $value and #code in turn.

If I type foreach and press tab in a php file but outside of php tags I will get:

<?php foreach ($variable as $key => $value): ?>

<?php endforeach ?>

There are tonnes snippets for loads of languages, and you can always supplement them with your own.

PACKAGE CONTROL

This package will make it much easy to manage some of the packages mentioned below, grab it here.

Autocomplete + SublimeCodeIntel package

Sublime comes with word completion (based on other words in the file) but the SublimeCodeIntel package improves it ten fold, you can install it using the Sublime Package Control.

I’ve been using it with PHP, which given its loosely typed nature, can be difficult to autocomplete but CodeIntel seems to do a pretty decent job.

Open recent files

You know when you close a tab in Chrome you can do cmd+shft+t and it opens again (well you do now) this plugin introduces the same functionality to sublime.

SublimeLinter

Checks the syntax of your files as you type, or on a save/open.

Soda theme

Sublime isn’t the worst looking IDE I’ve seen but this theme certainly improves on what is already there. In addition to installing via Package Control you will also need to enabled by adding:

"theme": "Soda Dark.sublime-theme",

to Preferences -> Global Settings – User

Standard stuff

Find, find & replace, Find in project

Pretty standard stuff here: regexp supported, case insensitive and sensitive, highlight matches, find in open, find in dir…

Project

Create Sublime project files to easily only directories and settings for them.

Layouts

Split file vertically, horizontally or both.

Syntax Highlighting

Sublime supports TextMates tmLanguage files, and tmTheme files so even if your using an obscure syntax if there is a package for TextMate you can use it in Sublime.

Could do better

The main weak point for me is the file manager, its perfectly good for finding files but it’s less good when it comes to tasks like creating, renaming and moving files and folders. Most of the functionality is there but the UI behaviour doesn’t match up with long established patterns that we are all used to in programs like Windows explorer and Finder. Moving files seems to be missing entirely.

One response to “Sublime Text 2: A new IDE

Leave a Reply

Your email address will not be published.