Created
March 12, 2009 05:48
-
-
Save Kimtaro/77928 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# TextMate command for very simple pretty-printing of SQL | |
print $stdin.readlines.join("\n").gsub(/ | |
( | |
SELECT (\s+ DISTINCT)? | | |
FROM | | |
(LEFT (\s+ OUTER)? | INNER)? \s* JOIN | | |
UNION | | |
WHERE | | |
GROUP \s+ BY | | |
ORDER \s+ BY | | |
LIMIT | |
) \s*/x, "\n" + '\1' + "\n\t") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment