Using SciTE with TextMate Style Snippets

Ever since watching Dustin Diaz’s first screencast, I was incredibly jealous of TextMate (specifically the keyboard triggered snippets). I was on a mission to find an alternative that wasn’t limited to Mac OS X as it was clear there wouldn’t be a Linux version of TextMate. There are quite a few suggestions on the TextMate site itself, but I found nothing that mimicked the Snippets functionality of TextMate properly. E TextEditor came out for Windows, making me even more jealous. Now there was an application for Windows that performed similarly to TextMate, and I had nothing to work with. The author of E indicated that there would eventually be a Linux version, but not until the Windows version was final. After a continued search, I finally came upon SciTE Snippets.

SciTE – My New Favorite Editor

SciTE is (freely) available for both Linux and Windows, but this article will dedicate itself to the Linux install process as it is the only environment in which I’ve set it up. Furthermore, the details of the installation process will be specific to Ubuntu 6.10, as it is my distribution of choice, but the install process itself should be similar on just about any version of Linux.

Installing SciTE

SciTE is easily available to install by executing the following in a terminal:

sudo apt-get install scite

After you enter your password, SciTE will be automatically installed and setup. You can also install SciTE using Synaptic Package Manager, but I prefer the command line. SciTE can be run by entering scite in the command line, or using the menu: Applications > Programming > SciTE Text Editor.

Screenshot of default SciTE installation

By default, SciTE doesn’t include the snippet functionality offered by TextMate, but incorporating all of the hard work by Mitchell, SciTE Snippets are easy to implement.

Implementing SciTE Snippets

I spent some time trying to grasp how to actually install the snippets plugin Mitchell developed. Following his documentation proved to be quite useful and I had SciTE Snippets up and running after a bit of trial and error. It involved a process that some people new to Linux may find intimidating, so I’ve decided I would try to use the SciTE binaries offered on the site. Not only do you get working Snippets, you’re provided with a new look and feel for SciTE itself. A large library of Snippets are included to work with and add upon and I found it to be a great starting point for using Snippets in SciTE.

The binaries Mitchell offers are stored on Google Code and available for Windows as well as Linux. Download the latest Linux Binaries (scite-tools_linux_bin_r3.tgz at the time of this writing) as well as the Source Code ( at the time of this writing) which will come in useful later.

Extract scite-tools_linux_bin_r3.tgz
tar xzvf scite-tools_linux_bin_r3.tgz
Copy the new SciTE binary over your installed version
cd scite-tools_linux_bin_r3
sudo mv /usr/bin/scite /usr/bin/scite.bak
sudo cp SciTE /usr/bin/scite

The binary has now been copied to your existing installation, it’s an updated version compared to the one offered in the Ubuntu repositories. You’ll notice that if you run SciTE, not much has changed; we’ll still need to copy over Mitchell’s configuration files as well as his included snippets.

Implement configuration and Snippets:
cd scite-tools_src_r3/
sudo cp -R * /usr/share/scite/

Just to be clear, not only have you copied over the configuration and included Snippets, you’ve also copied the source. If you feel the need to remove the extra files, feel free to do so. Now that the configuration files have been copied, you can run SciTE again, and you’ll see it’s received quite a makeover:

Screenshot of default SciTE installation

SciTE Snippets are now at your disposal using the CTRL+i keyboard combination after typing your trigger.

Customizing SciTE Snippets

While Mitchell includes many of his personal Snippets, I have a certain way of writing markup, style, and code. Each developer will want to make adjustments to existing snippets — as well as add some — in order to streamline his process even further and take full advantage of their presence. Managing your Snippets is actually quite easy if you follow the conventions established by Mitchell. Your snippets are stored in /usr/share/scite/scripts/ and organized according to language.

Creating Snippets is well documented on Mitchell’s site, and he even offers a Ruby Snippet Generation Script which can come in quite handy. Personally, I found the example Snippets offered in /usr/share/scite/scripts/html/snippets.lua to be most helpful in understanding Snippets and how they worked. I simply manage the snippets I wish to use in that file and it’s worked out well so far.

Mitchell has provided a really great tool for many people, free of charge. He has provided screencasts which show his Snippets in action, including a demonstration of how to use scopes, a very powerful feature he’s included.

Customizing the SciTE interface

When using SciTE for the first time, I was surprised not to find a Preferences dialog. Like anybody, I have preferences as to the type used in my editor, so I was looking to make that simple change. Instead of a Preferences dialog, you’ll need to edit a configuration file. While I’d much prefer to have a GUI dialog, having to edit a configuration file really isn’t that big of a deal to me, but I know many people would look at the application as inferior for that very reason.

Regardless, the configuration file can be edited by selecting Options > Open Global Options File within SciTE. The associated file holds all of the preferences you’ll want to tinker with to get SciTE to look just how you want it. If you’re using Mitchell’s configuration, you’ll notice he took the time to reorganize this file, making it very easy to manage.

SciTE (especially with Snippets) is my new favorite tool

I’ve found that creating Snippets can be a lengthy process, but one that offers great benefit. Using Snippets allows you to work at a much faster pace without getting ahead of yourself and losing focus. It takes away much of the tedious aspects that come with writing markup. The speed benefits alone made switching from Bluefish/Quanta worth it. I have a feeling that many editors will incorporate such a feature in their upcoming releases.

It goes without saying that SciTE has all of the features you would expect in an editor: line numbering, code folding, syntax highlighting, etc. I’m very pleased to make the switch to SciTE, and I definitely recommend it to anybody who isn’t willing to fork over the cash for a copy of E. I’ve only been working with SciTE a short time so far, so if anybody has any tips or tricks they’re willing to offer, it would be great to post them as a comment.