Moving from E-TextEditor to Sublime Text 2

August 5th, 2011

I’ve been using E-TextEditor for more than a year now for doing all my JavaScript, Node.js and CoffeeScript development. You can think of E-TextEditor as TextMate for the Windows platform. I’ve been pretty happy with it throughout this period as it can be extended pretty easily with a whole slew of bundles that are already available for TextMate. E-TextEditor requires you to install Cygwin which happens automatically during installation. Using the Cygwin command-line gave me enough (re-)exposure to a Linux-like environment in order for me wanting to (re-)learn about this other platform. More on that in later blog posts. Although there haven’t been any new versions of E-TextEditor for quite some time now, the current version enabled me to write JavaScript code in a productive way.

Only recently I found out about another editor called Sublime Text 2 (thanks to Ivan Porto Carrero). I downloaded this text editor in order to give it a try and I must say that I haven’t opened E-TextEditor ever since. This second version of Sublime Text is still in development but it’s pretty stable as I haven’t run into any issues so far. The cool part is that this editor is available for both Windows, Linux and OS X which enabled me to move all my Node.js and CoffeeScript development from Cygwin on Windows to Ubuntu Linux. 

CoffeeScript isn’t supported out-of-the-box (yet), so I installed the CoffeeScript  TextMate bundle written by Jeremy Ashkenas (yes, the same one from the CoffeeScript and Backbone.js fame). Also check out this page on the CoffeeScript wiki for more information on how to bring some CoffeeScript happiness to your own favorite text editor.

Setting up this TextMate bundle for use with Sublime Text 2 was actually pretty easy. Just navigate to /home/<my_user_name>/.config/sublime-text-2/Packages in a terminal (or the corresponding file path on Windows) and clone the source of the CoffeeScript TextMate bundle using git:

git clone git://github.com/jashkenas/coffee-script-tmbundle CoffeeScript

Next close all the .coffee files and restart Sublime Text 2. Now we have some nice syntax highlighting and some useful code snippets at our disposal. 

image

It’s also possible to hook into the build system of Sublime Text 2. You just need to create a new file named CoffeeScript.sublime-build at the following location:

/home/<my_user_name>/.config/sublime-text-2/Packages/User 

You can add the following to this new file for compiling CoffeeScript

{
     "cmd": ["coffee", "-c", "$file"],
     "selector" : "source.coffee",
     "path" : "/usr/local/bin"
}

or the following for executing/running CoffeeScript code.

{
     "cmd": ["coffee", "$file"],
     "selector" : "source.coffee",
     "path" : "/usr/local/bin"
}

Now when you hit F7, this fresh build command is executed when a CoffeeScript source file is showing in the active tab. It’s also possible to change the build short-key to your own taste through the Preferences menu.

Unfortunately, there’s only one build command as I would love to create a separate command for compiling and running CoffeeScript code (or perhaps I missed this feature during the excitement Winking smile).

Some more usage is definitely needed for me to learn more about this excellent text editor, but currently I’m pretty happy with it. I also need to find out how well JavaScript is supported and perhaps see how far one can go when doing some C# development using Mono. I expect that there are a good number of productive features in there for me to discover.

I encourage you have a decent look at this excellent tool.

Until next time.

  • dylan

    I’ve been really enjoying this too on my mac at home and windows at work, with dropbox to sync. I did a similar little build provider for markdown using pandoc (http://dylandoesdigits.posterous.com/markdown-to-html-the-easy-way) and have JSLint set up for js work. Thanks for sharing the coffeescript how to.

  • http://www.deploymentzone.com Charles Feduke

    I’m going to have to check this Sublime out.  I tried e, couldn’t really get into it (not a fan of Cygwin, what can I say?) but I’m a big TextMateoholic on OS X – though I have begun my descent into the vim abyss…

    • Anonymous

      vim is definitely on my menu as well. I think it’s going to be a huge investment but well worth it. 

      • Sean Williams

        Oh no… be careful of that VIM abyss… it’s hard to get out! VIM is crazy powerful, but I’ve only been writing code for about 10 years – well into the age of the arrow keys! I know that people who are used to using VIM will argue for hours on end about using hjkl to get around, but that’s just not for me. 

        Anyway, to the point of this comment:

        In the ST2 forums you can follow along with the dev builds to see what they are adding… Build 2101 was just released, but back in 2096 a “vintage” mode was added. Enabling vintage mode gives you a lot of VIM-like functionality. JPS (the developer) says that its expirimental and may not make it to release, but it may be worth checking out if you’re a VIM-a-holic. :) 
        You can read more here:http://www.sublimetext.com/forum/viewtopic.php?f=2&t=2609

        • Anonymous

          Thanks for the link. I’ll give it a look …

      • Sean Williams

        Oh no… be careful of that VIM abyss… it’s hard to get out! VIM is crazy powerful, but I’ve only been writing code for about 10 years – well into the age of the arrow keys! I know that people who are used to using VIM will argue for hours on end about using hjkl to get around, but that’s just not for me. 

        Anyway, to the point of this comment:

        In the ST2 forums you can follow along with the dev builds to see what they are adding… Build 2101 was just released, but back in 2096 a “vintage” mode was added. Enabling vintage mode gives you a lot of VIM-like functionality. JPS (the developer) says that its expirimental and may not make it to release, but it may be worth checking out if you’re a VIM-a-holic. :) 
        You can read more here:http://www.sublimetext.com/forum/viewtopic.php?f=2&t=2609

  • Sean Williams

    I just switched from Notepad++ to Sublime Text 2. I’ve tried it in the past and never gave it a chance… the thing that always threw me was the lack of code folding. But, this time I decided to really give it a chance and I can say now, after a couple weeks of use, that I absolutely love it! I still miss my code folding, but I’ve learned to get around the file without it.

    One tip I’d recommend to people who haven’t tried it yet is this: be sure to open up the default keybinds and read through them (Preferences -> “Keybindings – Default”). Use them, learn what they do. It was at that point that I realized how awesome ST2 really is.

    The other thing I wasn’t a huge fan of was the dark theme. At the office I have these glaring overhead lights – using a dark theme is too much contrast for me… I prefer to stick with a lighter theme. At home, in my low lit environment, I love the dark theme. Anyway, I found a light theme and haven’t looked back. You can find that theme here: https://github.com/buymeasoda/soda-theme

    • Anonymous

      I printed the default keybindings and changed some of them. Going over them is indeed a great idea to grasp the real power of ST2. Thanks for sharing.

    • Mirko Vukuši?

      BTW, latest develpoment version just included proper folding :)

  • Raif Harik

    Hi, I’m downloading sublime now, but have been using rubymine by jetbrains for some time.  It’s not the greatest but it has a lot of resharper hot keys and the like.  I look forward to trying sublime.

  • Raif Harik

    Hi, I’m downloading sublime now, but have been using rubymine by jetbrains for some time.  It’s not the greatest but it has a lot of resharper hot keys and the like.  I look forward to trying sublime.

    • Raif Harik

      some nice features for sure but I can’t live with out ctrl click to get to def and other resharper type commands.

  • Raif Harik

    Hi, I’m downloading sublime now, but have been using rubymine by jetbrains for some time.  It’s not the greatest but it has a lot of resharper hot keys and the like.  I look forward to trying sublime.

  • http://www.facebook.com/profile.php?id=1756374927 Anooj Muljee

    Hi, I’m on windows.

    I did the following steps:

    Deploying it:
    1. Downloaded the source
    2.
    Extracted the content and within %appdata%Sublime Text 2Packages  I
    created a folder called CoffeeScript in which I placed those extracted
    files within.

    The directory looks as follows: See the attached image therein.

    Building the system:
    1. I created a new file called “CoffeeScript.sublime-build” within which I pasted the following lines, as you explained:

    {
    “cmd”: ["coffee", "-c", "$file"],
    “selector” : “source.coffee”,
    “path” : “/usr/local/bin”
    }

    2. Then from Tool > Build System > I selected CoffeeScript
    3. After doing that,  then I hit on f7 to build it but it returned me with this error message:
    [Error 2] The system cannot find the file specified
    [Finished]

    Someone kindly help me to set it up. I am tired trying to make it to work.

    Thanks,
    Anooj

    • Samuel Lu

      Is the “path” Wrong?

    • http://lushisang.com Samuel Lu

      Are you download wrong files? This is right url: https://github.com/jashkenas/coffee-script-tmbundle .This is my file screenshot.

      • http://www.facebook.com/profile.php?id=1756374927 Anooj Muljee

        @SamuelLu:disqus Can you try to share me your ‘CoffeeScript.sublime-build’ ? I believe my path i.e. “path” : “/usr/local/bin” must be wrong as I copied the one that’s been given in this post. I realise that the given path within this post will differ as the author of this writeup is most probably on something like OSX while I am from Windows.

        Also, in this post if you read it well, @JanVanRyswyck:disqus writes:

        It’s also possible to hook into the build system of Sublime Text 2. You just need to create a new file named CoffeeScript.sublime-build at the following location:

        /home//.config/sublime-text-2/Packages/User

        Based from this, I also instead of putting the ‘CoffeeScript.sublime-build’ file within the /packages/CoffeeScript/ just like you did -  I instead blindly followed  the author of this writeup and I ended up into placing the same within instead /packages/user/ – as instructed by him.

        Try to share me your ‘CoffeeScript.sublime-build’, I would like to peep through the settings.

        p.s: Zen Coding isn’t working for me. Can you try helping?

        Thanks Samuel,
        Anooj

        • http://lushisang.com Samuel Lu

          This is my content in “CoffeeScript.sublime-build”:

          {
          “cmd”: ["coffee", "-c", "$file"],
          “selector” : “source.coffee”,
          “path” : “D:/Program/CoffeeScript-Compiler-for-Windows”,
          “file_regex”: “^Error: In (…*?), Parse error on line ([0-9]*):?”
          }

          The path is CoffeeScript Compiler for Windows( https://github.com/alisey/CoffeeScript-Compiler-for-Windows). Either position of “CoffeeScript.sublime-build” is OK.

          I have’t known “Zen Coding” before, so I can’t help you. :)