Thursday, 27 August 2009

Syntax Highlighting for SQL

Today I decided I can be a choosey chap.

Unhappy with the basic <pre> syntax for pre-formatted text such as my SQL queries and output, I was on the hunt for a Syntax Highlighter to suit my satisfaction.

Part of this search entailed reviewing how other bloggers do it, but considering I read most of my feeds through Google Reader, I don't see as much of the magic.

I like the way Laurent Schneider formats his, but I think it may be internal and cumbersome.

I found a bunch of reviews here.

A common/popular one seems to be Syntax Highlighter by Alex Gorbatchev. I've applied this to my blog although I'm not entirely happy with it.

I don't know if it's my penchant for SQL*Plus, or my softer choice of highlight colours in TextPad, but I don't like the colour choice of the strings or certain keywords - I mean, pink for aggregate functions? I had a look at the source and it doesn't seem immediately obvious how to customise these. I need the .js/.css files externally hosted anyway because I can't host them in blogger nor Google Docs.

It looks cleaner without the line numbers - I think I'll only add those when I want to mention particular lines.

It also comes out quite small in Google Chrome - a browser I find myself using more and more - can't wait for XMarks to be available in Chrome.

I also tried Google Code Prettifier, althought it seemed to have minimal effect on SQL bar drawing a box around my code.

I don't know if I'm being picky or if there just isn't much out there for SQL. If anyone has any suggestions, I'd more than welcome them.


Laurent Schneider said...

Thanks for the plaudit!

I had guidelines in my book, regarding how to indent code, like an indent size of 3. But in my blog I like to have an indent of 2.

I also love oneliner, so when I have less than 80 chars, I keep it one line as far as possible.

However to keep an uniform code style in team, it is best to agree on a common formatter, otherwise each developer change will screw up your versioning...

Laurent Schneider said...
This comment has been removed by the author.
Laurent Schneider said...

I also blogged about sqlinform on SELECT*FROM"EMP"WHERE'SCOTT'="ENAME"AND"DEPTNO"=20