I’ve used it as my main editor these past few days to give it a fair chance to impress me and it hasn’t let me down yet. Sublime bills itself as, “The text editor you’ll fall in love with,” and I can easily see that happening.
Sublime has features that you’ll love no matter what you’re writing, whether it be code, prose, or poetry.
I thought I’d write a little bit about why I like it so much, as well as encourage you to at least try it for yourself. If you’re in the market for a new editor, this will be where your search ends.
The first impression that Sublime Text gives is that it’s beautiful. I can’t say that I’ve used any other program that makes editing so attractive. Sublime Text is not lying on its features page when it cites a “Beautiful User Interface”. Some editors have nice looking themes and color schemes, but the themes I’ve used so far (My favorite is Monokai; yes, from TextMate, but more on that later) have all been pleasant and understated; they really help you focus on what you’re writing, rather than distracting you with flashy and/or clashing color schemes.
Another feature of sublime is the variety of ways to organize your files on the screen. You can display multiple files at once in the same window, with 2, 3, or 4 panes side-by-side, 2 panes open horizontally, or even 4 panes with one in each corner. You even get tabbed browsing in each pane as well. Talk about convenient! You might be thinking this would be cumbersome to deal with, changing the layout of the panes, switching between different panes, and tabbing through the files open in each pane. Well, it’s really very intuitive, as all these operations are bound to a convenient shortcut (as is everything else in this program), so you barely even notice having to deal with these issues. The biggest point that should be made though is that all of these operations are possible without touching the mouse. (This may sound like a small point but can make a big difference in your typing speed.)
I find this feature very convenient since its trivial to open a new buffer, jot some notes down, and then either move it to its own pane or just tab it behind your other files. It also means you don’t have five Sublime windows open, clogging your screen, but just one which has all your documents in it. Despite the fact that I’m talking about text editors, a picture is worth a thousand words, so look at the picture (if you haven’t yet) to see what I’m talking about.
If you look at that picture, you may notice that there is a small box in a column next to the text. That’s the minimap which is the “view from 10,000 feet” of your file. It’s a pretty neat and easy way to view as well as navigate your text. Very helpful if you wanted to flip through chapters of your book or find that one block of code quickly. And if you don’t like them, you can just turn them off.
A few of you may be saying, “Sam, I know you like having tons of panes and tabs open, but that’s too distracting to me. I’ll just keep loo-” Wait! I personally like lots of files open at once, but if you want distraction free writing, similar to WriteRoom, there’s a mode for that. It’s called, you guessed it, distraction-free mode(!) and its just a simple F11 press away. Take a look at it. If you decide that you like full screen but still want panes and tabs, you can still use them like normal in full screen mode, they just don’t display the menu bars.
So now I think you can see that Sublime Text has a lot of features to make editing text attractive. But you’ve probably seen a lot of ‘pretty’ editors out there that lack the power to make your coding easier. Well, you’re in luck, because Sublime has tons of features that programmers want.
One feature that I was almost shocked to see was auto-completion. Auto-completion from a text editor? That’s right. It’s pretty good and will even auto-complete symbols you declare in that file.
Syntax highlighting is pretty much expected these days and Sublime delivers a huge amount of languages, with even more available through plugins.
A neat feature of Sublime that I’ve never really used before in any other editor is snippets. Basically, you start typing a common phrase, press tab, and *poof* you have a filled out block of code! There are some pretty neat ones available, such as HTML headers, C++ structures with #ifdef statements, and hundreds more depending on what language you are using. I haven’t become familiar with many yet other than just glancing at the list, but I have a feeling this will make me much more productive once I master them. Once again, if you don’t see a snippet you want, it’s trivial to add your own.
In fact, all key-bindings, snippets, and even the menus are stored XML files. This means that if you don’t like nearly any setting, you can just change it. You can add your own menu with commands you use most often and then give them custom keybindings (or just one of the two). Heck, if you don’t like your menu being called File, you could call it the ‘Llama’ menu. This program really lets you do whatever you want so that it fits your needs exactly.
One thing that I was disappointed with was that there was no version control integration with Mercurial, my version control system of choice. That is, until I started reading about the powerful plugin architecture and wrote a tool for it myself! The author of Sublime Text probably realized he can’t fill every single need out of the box, so he provided the tools for end users to improve it themselves through a complete Python environment and plugin API. Using Python as an extension language was a great choice because now users can use the huge amount of Python code publicly available, some users may already know it, and the developer can focus on developing the editor, rather than creating an extension language. The author of the software discusses the reasons he chose Python here.
Another cool feature about the use of Python is that it’s an interpreted language. This means that changes happen the moment you add or change your Python file; no need to compile your plugins and scripts. Yay!
The fact that users could extend the software with Python was really exciting to me because already I know and like Python. Using the API for Sublime was a little difficult to figure out, but other users were very helpful on the forum. Since the feature I wanted wasn’t there, I wrote a plugin that provides access to frequently used Mercurial commands from within the editor. You can get it for free here. This allows me to do the bulk of my version control from within the editor without using a command prompt.
Writing the plugin was a lot of fun and I actually got a really good Python snippet out of it, which I posted below. The snippet runs an external command through a shell and captures both stderr and stdout and then displays any errors that occurred or just the regular output. I hope you find it useful.
# Runs a system command from the command line # Captures and returns both stdout and stderr as an array, in that respective order def doSystemCommand(commandText): p = subprocess.Popen(commandText, shell=True, bufsize=1024, stdout=subprocess.PIPE, stderr=subprocess.PIPE) p.wait() stdout = p.stdout stderr = p.stderr return [stdout.read(),stderr.read()] # Displays given stderr if its not blank, otherwise displays stdout # Method of display is configured using the Mode argument # # Results is of the form # Results is stdout to display # Results is stderr which, if its not None, will be displayed instead of stdout # # Modes: # Window - Opens a new buffer with output # MessageBox - Creates a messageBox with output # # view is the view that will be used to create new buffers def displayResults(Results, Mode, view): if(Mode == "Window"): if(Results != None and Results != ""): createWindowWithText(view, "An error or warning occurred:\n\n" + str(Results)) elif(Results != None and Results != ""): createWindowWithText(view, str(Results)) # Message Box elif(Mode == "MessageBox"): if(Results != None and Results != ""): sublime.messageBox("An error or warning occurred:\n\n" + str(Results)) elif(Results != None and Results != ""): sublime.statusMessage(str(Results))
You can find the full code for the plugin online here.
I briefly mentioned that I was using the Monokai theme from TextMate earlier in this post. Well, in the spirit of letting users extend their editor as they see fit, Sublime Text can actually use TextMate syntax files now. This means that in addition to writing your own plugins and scripts, you can now use the work that others have contributed to the TextMate editor.
A final note is that nearly every single command has a keystroke associated with it. This can really save you a lot of time fiddling with the mouse and navigating menus. It’s just so convenient to use a keystroke to do what you want rather than the mouse, but that may just be the VIM user in me talking. And as always, if you don’t like a binding, that’s just a small change you can make in your XML file.
Overall, I get the impression that the developer of Sublime Text, Jon Skinner, really understands what makes a great editor and what his users want. Its clear he also understands that everyone has different preferences. Because of this, the editor is very customizable (as I’ve mentioned many times) and you can really make it your own.
Jon is also present on the forums and even answers emails from users (like me!); he really cares about his users.
I know I’ve thrown a lot of information at you, so allow me to summarize for you. (Or sum up the whole post if you didn’t read it, you bum.)
- This is a beautiful program to edit with.
- Pretty themes and colors.
- Lots of ways to effectively view your files.
- Multiple panes and tabs help to organize your files and maximize your productivity,
- A distraction-free mode for when you really need to focus.
- Minimap for quick navigation.
- Tons of features to benefit programmers,
- Auto-completion just a keystroke away.
- Syntax highlighting.
- Completely customizable
- Nearly every setting is stored in an XML file, allowing for quick changes.
- Changes happen in real time.
- Support for TextMate syntax files.
- Powerful plugin API
- Python gives you the power to extend the program in tons of ways.
- The feature you want not there? Then make it!
I really hope that I’ve convinced you that Sublime Text is an excellent editor and that you’re chomping at the bit to get it! For those of you who aren’t quite so enthusiastic, I hope you’re at least willing to try the free trial. Licenses for it are $59, which is a very reasonable price for the quality of product that you’re getting.
After using this program, I’m very happy with it and now my quest for the perfect editor is over!