Using SciTE with TextMate Style Snippets

Posted: March 12, 2007 Comments(18)

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 (scite-tools_src_r3.zip 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.

Extract scite-tools_src_r3.zip:
unzip scite-tools_src_r3.zip
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.

Get my newsletter

Receive periodic updates right in the mail!
  • This field is for validation purposes and should be left unchanged.

Comments

  1. You can do this with the perfect text-editor «vim» as well 🙂 Oh, maybe not the scope. I don’t use that.

    But vim is not for everyone, so very good that you made this tutorial. It is good that there exists other usable text editing programs for Linux 🙂 I’m glad you found one you could love. (And not make you feel jealous of OS X-people)

  2. @Odin/Velmont: I had also read that something like Snippets were possible using vim, but as you had mentioned, I just can’t get the hang of vim and prefer to use something like SciTE. I haven’t messed around with the scope much yet, but it looks to be quite a powerful feature in certain circumstances. So far, it’s working out great.

  3. For people using Linux/GNOME, the latest versions (releases, too) have similar support out of the box. Even the syntax of the snippets is very similar to that of TextMate.

  4. @Veracon: I wasn’t aware that Snippets were integrated into the release… that’s great news! Thanks for sharing.

  5. Thanks for this post. However, after looking around, I think gEdit incorporates these features already, maybe even directly from the ScITE project. Since you’re using Ubuntu Edgy, I thought you’d like to know. Just check out the ‘Plugins’ option in the gEdit preferences. I’m still stoked about the ability to alter the indents of several lines at once!

    Great post though. I too am in the process of mastering the art of being a designer on Linux.

  6. @Dan: I hope you find it useful.

    @Simanek: Wow, I had no idea. I know I’ve looked at gedit plugins before, but I don’t remember seeing this. Was it recently added? I just gave it a quick try and it seems to work very well. The only issue I run into with gedit is that sometimes syntax highlighting is a bit flaky. Thanks for the tip!

  7. I have to agree with Jon – in my quest for a suitable and easy to use editor, I didn’t quite like gedit (although I am not excluding it entirely).
    For web development, my choice was set on Quanta Plus and Aptana IDE under Linux. On Windows, Notepad2 and occasionally Dreamweaver

  8. Great post, Jon. I’m absolutely in love or “intoxicated” as you once said to me, by using Linux; and using it for web design and development has been a dream come true. Once you feel comfortable with Linux there’s really no reason to be jealous of the Mac-guys anymore.

  9. Oh, and I forgot to mention that I agree with you, SciTE with snippets is completely awesome. Thanks for the tut on how to include snippets, btw. I was having a hard time implementing it on my own.

  10. @dan: I was using Quanta for some time as well, but I prefer Gnome over KDE and although Quanta is a fantastic editor, it still irked me a bit.

    @Ben G.: The comments here have shown that there are indeed other apps that work with snippets, but I’m going to stick with SciTE, I really like it.

  11. Might also want to check out scribes.

    Seems like a great editor – only it doesn’t support multiple open files which really sucks.

    Also, e-text-editor works (somewhat) through Wine.

    -Rob
    (using ubuntu fesity)

  12. Okay, just getting back to you here. I’m just getting around to really start taking advantage of the snippets mechanism. The added ‘tags’ that can be placed into the snippets to include dynamic information as well as tab markers within the snippet (the img tag is a good one for this). It’s great to see a major interface convention that has nothing to do with graphic presentation and everything to do with text-based simplicity.

Leave a Reply

Your email address will not be published. Required fields are marked *