2 ms·
For the SQL case, you can just use a different formatting that puts aligned items into blocks, something like: SELECT this_column, that_column
by MrJohz 2y ago
For the SQL case, you can just use a different formatting that puts aligned items into blocks, something like:
SELECT
this_column,
that_column
FROM tablename
WHERE
this_column = 1
AND that_column IS NOT NULL
(The AND token could go either where it is, or at the end of the previous line, depending on your preferences - I prefer the clarity of putting the operator first here over the alignment of the column names, but I can see both sides.)
It might not be your preference, but that's always going to be the case with formatting.
With the comments, that's a good point. I'd generally prefer to use double comments for anything that spans multiple lines, but if you're creating a formatter you need to handle any syntax thrown your way. You could try formatting it without the leading space, but that would be very unusual, or keep the leading space and have it as the one exception to the rule. Or just not format comments, I guess.