Saturday, January 7, 2012

Installing Packages for Sublime Text 2 on Linux

I decided to give Sublime Text 2 a try on the next sprint on my current project. I've heard a lot of great things about it and have been impressed in the bit of messing around I've done thus far, and as I've said before although CFEclipse rocks for CFML development after using it for years and years Eclipse is just starting to feel like a lot more than I need. Eclipse is great for the Groovy and Java work that I do but for CFML I've been looking for something more lightweight, because for CFML work I tend to use Eclipse as a pretty basic editor and file navigator. Like most programmers I also tend to get bored and simply want to try new things once in a while.
I used emacs on the last round of updates to the OpenBD admin console. I really, really like emacs but you're stuck with using the HTML syntax highlighting and code formatting since there's no CFML plugin for emacs (that I could find anyway), so it falls over pretty hard if you try to do too much CFSCRIPT. I also use vim quite a lot as an editor but for full-blown project work I've never made the switch for whatever reason. I'm also a big fan of UltraEdit and although they do have a Linux version, it's pretty sluggish. Hopefully that'll get better in newer releases.
But I digress--the real point of this post is a quick tip on where to put Sublime Text packages on Linux. Not a huge thing but I figured I'd share since I did have to do a bit of hunting around. Even though Sublime Text is available for Linux (which is awesome), most of the information around this assumes you're using either Windows or Mac.
After you extract Sublime Text 2 and run it for the first time it creates the directory ~/.config/sublime-text-2 and this is where you put your packages. You just copy the directory containing the package you want to install into ~/.config/sublime-text-2/Packages, restart Sublime Text, and you're done.
Let's use the ColdFusion Plugin as an example. After unzipping the plugin, you'll copy the ColdFusion directory (the entire directory, not just the contents) into ~/.config/sublime-text-2/Packages so you'll wind up with the directory ~/.config/sublime-text-2/Packages/ColdFusion Restart Sublime Text and if you go to View -> Syntax you'll see ColdFusion in the list.
Note that in some of the Mac instructions I found they indicated you have to also add a symlink in ~/.config/sublime-text-2/Installed Packages that points to the directory of the package. I did that first and it works but given that all the other packages in ~/.config/sublime-text-2/Packages show up in the menus, I decided to delete the symlink and after restarting Sublime Text everything still works.
I'll be using Sublime Text 2 hot and heavy over the next few weeks so I'll share my experience with it. If you have any tips for a n00b or stuff that tripped you up when you first started using Sublime Text I'd love to hear them.

8 comments:

Dominic Watson said...

Check out the package-control plugin. Once installed, you get a proper package manager in Sublime (that is lightening fast). The ColdFusion plugin is listed in its repo too :).

http://wbond.net/sublime_packages/package_control

(and works just dandy in Linux and Windows, presumably in OSX too)

Matt Woodward said...

Thanks Dominic -- just came across that when I installed Sublime Text on another machine recently and it is indeed pretty slick.

a said...

Is there a syntax checker for coldfusion sublime? like a big red red in the gutter when you have missing cfif etc?

Just trying out sublime and it looks very nice a syntax check would make it better

Matt Woodward said...

Not that I know of, but I haven't dug into all the ins and outs of Sublime yet. Been too productive to go beyond the basics I guess. ;-)

That would indeed be a nice addition but as far as I know there isn't one.

a said...

ok thanks. The other sticking point for me which I cant seem to find an answer for is the syntax highlighing of different html elements.

form & inputs orange, divs blue or whatever.

I know it is possible as i have hacked the html language file to identify form elements, but the fact that this was a new install and the html language file did not have any hooks for theming forms etc makes me think its not a html editing tool thats widely used?? I cant see that people dealing with html everyday would have such a flat pallete ie all tags the same colour? maybe i am missing something? but i have looked for screenshots of html in sublime and in every one the html tags are the same colour for every html tag

Matt Woodward said...

Interesting, I'm not sure I've ever used an editor where each *tag* is a different color. Typically (at least in the ones I've used) tags might be a different color than attributes inside tags, but I guess I've never used one where a table tag would be a different color than a select tag, for example.

I haven't dug into this too deeply yet (still on my to do list) but from what I understand the plugin development is pretty straight-forward, and is very similar (might even be identical) to the plugin format of TextMate. So if for example you know TextMate does the syntax highlighting you want you could port that over to Sublime without too much trouble from what I understand.

a said...

thanks Matt, I guess i am old school back to homesite, coldfusion studio then to cfeclipse. Think they all had html highlighting and white backgrounds.

here are a couple of examples of what i mean.

http://www.nebo3.org/images/2.jpg

http://www.solotuweb.org/files/screenshots/homesite.jpg

switching editor is something that takes a while to get used to and "work" gets in the way! I am sure its possible to get it set up, but like everyone don't have the time to get it going.

I think you would need to alter the html language file to get more granular hooks, in that file all the tags are grouped together. Was just abit surprised that it wasn't already like that, which then got me thinking that it isn't the editor of choice for html guys? Would be interesting to see screen shots of different guys cfm, html code, what colour's your form tag? :-)

Sublime looks gorgeous though so might have a look again when i have more time.

a said...

found this, might be little project for get hub to split out the html tags, if i get round to it

http://lists.macromates.com/textmate/2011-January/032082.html

RE: How to change tag coloring?