Hacker News new | past | comments | ask | show | jobs | submit login

I'll have to see if I can adapt this to my somewhat idiosyncratic syntax:

  SELECT field, other_field
    FROM table
   WHERE some_thing IN (
         SELECT id 
           FROM other_table
         )
     AND other_field IS NOT NULL
(mostly it's right-aligning keywords, but there are a few other weird tweaks)



I tried your SQL in the demo, and it came out like this:

    SELECT
        field,
        other_field
    FROM
        TABLE
    WHERE
        some_thing IN (
            SELECT
                id
            FROM
                other_table)
            AND other_field IS NOT NULL
I'd have expected the last line to have one less indentation level...


sql-indent for Emacs supports that: https://github.com/alex-hhh/emacs-sql-indent



I’ve adopted the same format myself, it reminds me of aligning numbers at the decimal point.


I do similar, keeps both keywords and fields vertically aligned.


I do too, but it breaks down on me for some specific:

* ORDER BY

* INNER JOIN

etc




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: