Bryan Says...

Rants, opinions, and other stuff I find interesting.

My new funky editor. A story about Sublime Text 2

A prologue

Today, I use Sublime Text 2 for just about all my text editing needs. It is fast and fairly stable. It is customizable and it can use plugins from Textmate. It also allows me to have split windows and its concept for finding files, methods, and editor actions make me a productive developer.

Over the years, I’ve used a myriad of text editors. Most of my time has been spent in Vim. My fingers are so used to Vim’s modal editing, I tend to expect the world to move up or down when I press j or k. Every time I’ve tried out new editors, I’ve always missed h/j/k/l. Sublime Text 2′s Vintage editing mode satisfies most of my modal editing needs. All the important commands are there, and new ones are added as users request them.

One big issue I’ve had with editors that can be extended by code, is that the language used for extension isn’t very friendly. I’m not well versed in Lisp, but I can get around. Emac’s ability to be customized is unsurpassed, but personally I don’t feel that I need a complex environment with an editor as a bonus. Most times I just want to create text. On the other hand, Emac’s Org Mode is unsurpassed, so I do find myself wishing that it existed in other places with the same amount of functionality as the the original.

Vim’s vimscript is more than functional. It can be used to create some truly useful plugins. Tim Pope has proven this time and time again. The problem with vimscript is that is really only useful inside of vim. Vim also allows you to extend it using other languages, such as Python and Ruby, but I haven’t explored either of those enough to comment on them.

I tried Sublime Text 2 as a diversion from my normal editor, MacVim. I’d been hearing many things about it, so I wanted to try it out. It passed the 5 minute red face test with ease, so I decided to use it exclusively for a two week period. That was over a month ago, and now I’ve purchased it as well.

Why have I stayed in Sublime Text 2 for so long?

The obvious first response to this question is because it isn’t bad on the eyes. I like soft pastel colors on a dark background, and I wasn’t disappointed with what I saw.

Sublime Text 2's pretty colors

I learned a long time ago that the keyboard is the fastest way to navigate, so I require my editing environment to be fully driven by the keyboard. Finding files is as simple as pressing ⌘P (I use a Mac) and typing a combination of the path and the file name. The interface is fuzzy, so you don’t need to type all the characters to find things in a hurry.

Find files quickly!

There are also ways to find methods/functions in your current file and run commands quickly as well.

Command and Goto Symbol

You didn’t have to read this blog post to see those in action. You could have went to Sublime Text’s home page to see them detailed. I want to share why I’m not moving away from this editor in the foreseeable future.

As I said before, I don’t like to use the mouse. I avoid it to the point of shedding a single silent tear every time I have to use it. Keyboard navigation in ST2 (as I will refer to it from now on) is more than sufficient. You can create files and move between buffers with keystrokes. I can even bring up a Quake style console to see editor output, and show off my elite Python skills if I need to.

ST2's console

As we all know, all problems in computer science have already been solved. (At least that’s what I like to think) Sometimes we need to look to past to solve the problems in front of us. Looking to the past, we find Textmate’s snippet and theming system. Instead of creating yet a new format, ST2 allows you to import Textmate bundles. Problem solved.

You’d be mistaken if you thought that ST2 was just a new skinned Textmate, however. ST2 brings its own configuration to the table as well. It isn’t strictly a Mac style preference dialog, but it’s JSON back configuration is pretty easy to learn.

ST2's preference dialog

ST2′s plugins are all written in Python. Python isn’t too hard to learn if you programmed in any other C style language, and there are already plenty of plugin samples to base your new code off of. The plugins have access to basics, like your where your caret is, what lines you have highlighted, and the details about the current files. Plenty of people have written plugins to extend ST2 to their liking.

I’m currently following the Dev releases of ST2. What this means that I get new and fixed editor functionality a couple times of week. In the past month of using ST2, I’ve seen improvements to editor stability and new features. It’s like Christmas for my editor twice a week.

I’m sure at this point (if they’ve made it this far), that all the emacs and vim people are shaking their heads. Those editors do all this and more. If you are shaking your head, you are missing the point. There is plenty of room for improvement and usability. ST2 is just another attempt at finding that sweet spot. Usage of any editor is not an admission of disdain for any other environment. My vim code folding screencast is still the most popular post on this site. I’m happy to have found something to give me the energy to write blog posts again.

So, now I’ve been using this editor for a while now, and now it is time to make it mine. Stay tuned for part two of this series where I share how I’ve molded the editor to match my coding style.

  • Fanny Flappenhouser

    Tim Pope, not Tim Pop ;)

  • http://smartic.us bryanl

    good catch. hopefully he won’t see that i typo’d his name :)

  • http://blog.mmediasys.com Luis Lavena

    Is also worth mentioning that changing any of the settings and preferences it applies immediately so you don’t need to restart or anything to see them in action.

    Also is good to install Package Control and with it things like Alignment, Git and others.

    http://wbond.net/sublime_packages/package_control

    Long gone the days of cd’ing into Application Support and doing git pull to your bundles ;-) 

  • Martijn

    I’m torn.. I love Vim and wouldn’t want to miss it’s sophisticated movements and commands after 2 years, but Sublime Text has most of that and on top of that it’s easier on the eyes. Though choice..

  • http://canweriotnow.github.com/ Jason Lewis

    I’ve slowly been transitioning to Sublime from Textmate over the past month or so, mainly because Textmate development has been stalled for so long. The transition from Vim to Textmate was a tough one for me, and using Sublime with Vintage mode is totally the best of both worlds.