Switching from Coda to Sublime Text 2...

Sublime
written by Boris Strahija on February 23, 2012 in Blog with 9 comments

Recently I haven’t been to happy with my code editor, Coda. The clips (snippets) are way to limited, it’s very slow when opening larger CSS files, the Sites feature looks nice, but is also very slow when you have a whole bunch of sites in there. Don’t get me wrong, it’s a great editor, and it has some amazing features, but I feel it lacks where it matters most. Since I’m mainly a PHP developer, the article is written from my perspective, as I do work in PHP, HTML, CSS, LESS and JavaScript.

In the last 2 weeks I’ve been using mostly Sublime Text alongside Coda, because I thought this would be the best way to compare the 2 editors. I could have thrown another editor into the mix, but I don’t think any of the ones I tried don’t come close to ST2. Some editors I tried to switch to over the last couple of months are Espresso, Komodo and TextMate. So here’s a couple of word about them:

Espresso is the closest to Coda. It does some things better, and some not, wasn’t really impressed with it.

Komodo is an IDE (also has a free editor-only version), and it was actually pretty good, but the UI is just awful, and the setting are overwhelming.

TextMate is a great editor, but it has some problems with speed when opening large files, and it hasn’t been updated for a long time. A public beta of TextMate 2 was released recently, but it’s still to early to tell how it’s going to stack up to Sublime Text. I actually used TM a couple of years ago, and Sublime Text feels like TextMate, but snappier and with a ton of added features. And what I miss most in TextMate is the ability to perform quick file uploads, like in Coda. Sublime Text has this through a package, but more about this below.

Coda

I’ve been using Coda almost exclusively for the last 2 years. I love the ability to quickly publish files to a server. I know a lot of people are against this kind of workflow, for when uploading to a test/dev server this is a real timesaver. For everything else I started using Beanstalk and their deployment system. Or sometimes a “git pull origin master” will do just fine ;)

The built in Books tab is also very nice, but I haven’t been using that much. I find myself most of the time just googling stuff.

Same thing with the built in terminal, not using it at all, feels somewhat slow. TotalTerminal is a better way to go.

The preview tab is useless to me, I don’t remember that I used it at all. I know some people like having a preview directly in the editor, I’m just not one of them.

Through the years I got a nice collection of Clips setup, but they are inferior to the Snippets in Sublime Text. What I like most about the Clips is that they are extremely easy to set up and categorize, but the lack of multiple placeholders is a big disadvantage. Snippets management in Sublime Text is a little bit clumsy, since you have to edit XML files, and manually save them, and add the extension .sublime-snippet every time. I also wish I could add more snippets to a single XML file.

The settings in Coda are more user friendly, since they are like a normal settings dialog you’re used to in other apps. Sublime Text takes a different approach here, JSON files. I personally like it this way, but some users may prefer the standard settings dialog of Coda. Sublime Text is much more flexible this way in my opinion.

The UI in Coda is great. It’s been one of my favorite apps in terms of looks. Sublime Text doesn’t really have an UI, it gets out of the way, and focuses on the editor. One thing is bothering me though in Sublime Text, the sidebar. It’s extremely difficult to navigate through the files via the sidebar, since there are no icons. It’s all just text, so it’ hard to distinguish let’s say PHP files from CSS files. This isn’t that big a disadvantage since there are other ways to finding files in projects.

The last one is probably the least important thing, but Coda has a beautiful dock icon, whereas Sublime Text had a horrible icon up until recently. It’s better now, but still not as elegant as Coda.

Sublime Text 2

There’s way to much good stuff in here to write it all down, so I’m just gonna mention my favorite features. And keep in mind that Sublime Text 2 is still in beta, but stable enough in my opinion. I didn’t experience any crashes or weird bugs until now.

Speed

It’s just amazing how fast this app is. Even with extremely big files and a bunch of packages installed, I haven’t had any problems. Everything just feels so much more responsive.

Snippets and bundles

if you used TextMate or E Text Editor you now about how snippets work. You can use TextMate bundles so that’s a big plus. To manage your snippets you have to edit XML files stored in ~/Library/Application Support/Sublime Text 2/Packages/User. You can also create new snippets directly from Sublime Text, which present you with a template for a new snippet. You have to save the snippet XML file, and give it the extension .sublime-snippet which I think should be done through some kind of snippet manager like in TextMate. This would make is much more user friendly.

File navigation

As I mentioned before, the navigation in the sidebar isn’t very good because of the lack of file/folder icons. VCS indicators would also be a nice touch, but I guess that would degrade the performance, or I may be wrong. Since I didn’t like the sidebar, I had to find an alternative, and it turns out there’s the shortcut Command+P for quickly finding a file. It’s similar to Ctrl+Q in Coda, but works better and faster. You don’t even need to type in the exact name of the file, so if I want to open the file _post_types.php in a WordPress project I hit Command+P or Command+T, enter pty, and there it is.

Method/variable navigation

When editing a class, I just hit Command+R, and start typing the name of the method I’m looking for. This is really useful, and I think better than Coda’s code navigator. One useful thing I noticed is that when you press Command+R, remove the @ sign, and enter the # sign, you can search through variables. I found this way of navigation is faster, but I’m still getting used to it.

Publishing to server

This one I used in Coda a lot when developing. Coda has the convenient shortcut Command+Alt+P to publish the selected file in the sidebar to the associated server in the project. Coda also keeps track of all the changed files so you can publish them all at once. One of my biggest concerns was if something like this was possible in Sublime Text, since it’s a real time saver. It turns out there’s a package for that called Sublime SFTP. It’s not free, but well worth the 16$. I didn’t like the default keyboard shortcuts so I changed them, and now I have my shortcut from Coda (Command+Alt+P) back :) The SFTP package has also some nice sync features, file monitoring, and it’s really easy to setup a server, just right click on a folder and map to a remote folder. This creates a JSON file called sftp-config.json. Fill out the data and you’re good to go. I prefer using public/private keys for connection, since the password would be stored here as plain text. Some kind of Keychain support would be nice here.

Color schemes/themes

In Coda I enjoyed a slightly modified Special Boards color scheme. Since it’s not available for TextMate/Sublime Text and I currently don’t have time to recreate it, I found the next best thing for my needs, the Tomorrow Night scheme (preview). The default Sublime Text theme is ok, but when you install Soda (especially the dark version) it really starts to look nice.

Multiple cursors

Now this one I like a lot. You basically put the cursor anywhere inside the code, hold Command+Alt and start clicking to put another cursor into the document. Now when you start typing, you edit the code in all the selected places. Coda had something similar with the Alt selection, but Sublime’s version is more powerful.

Selecting words

When you select a word in a file it’s not only highlighted in the editor but also in the minimap. Very nice.

Packages

I could go on but the best thing would be to try it out for yourself. I’ll probably update this post as I find new things, for now though I leave you with a list of my installed packages that I use daily:

  1. Package Control – you’ll want to install this one first since it makes installing other packages really easy
  2. Git – I mostly use Git through the command line, but it’s nice to have this in the editor also
  3. SidebarGit – Git commands from the sidebar
  4. BracketHighlighter – highlighting your brackets in many different ways
  5. ColorPicker – the name says it all
  6. DocBlockr – adding comments to classes and methods
  7. GotoDocumentation – jump to documentation for selected word
  8. SFTP – uploading/downloading files to remote servers
  9. Alignment – aligning multiline selections, like a list of variables
  10. SidebarEnhancements – extra functionality in your sidebar
  11. CodeIntel – better autocomplete
  12. ZenCoding – I think you all know this one
  13. Soda Theme – last but definitely not least, this one makes the entire look of the editor more enjoyable