Skip to main content

SELECT Item Styles

Controls how SELECT items are positioned. Five styles available:

  • INLINE: All items on one line (SELECT A, B, C)
  • BODY: First item on keyword line, rest indented (SELECT A,\n B,\n C)
  • STACKED: All items on new lines after keyword (SELECT\n A,\n B,\n C)
  • FIRST_ON_KEYWORD: First on keyword line, rest aligned under first (SELECT A,\n B,\n C)
  • ADAPTIVE: Adapts to original input layout (default)

Interaction with commaStyle: Leading comma works with all styles. With FIRST_ON_KEYWORD + leading comma: SELECT A\n , B\n , C.

Interaction with indentWidth: BODY and STACKED use indentWidth for indentation. FIRST_ON_KEYWORD aligns to keyword width (e.g., 7 for SELECT, 9 for GROUP BY).

BODY trailing comma style

select a, b, c from t
select a, b, c from t

Trailing comma with custom indent

select a, b, c from t
select a, b, c from t

Leading comma style

select a, b, c from t
select a, b, c from t

Leading comma without newline is noop

select a, b, c from t
select a, b, c from t

Subquery with select item newline

select a, b from t where a in (select c, d from t2)
select a, b from t where a in (select c, d from t2)

STACKED style — all items on new lines after keyword

select a, b, c from t
select a, b, c from t

STACKED with custom indent

select a, b, c from t
select a, b, c from t

STACKED with leading comma

select a, b, c from t
select a, b, c from t

STACKED single item

Single item still starts on new line with STACKED.

select a from t
select a from t

STACKED with subquery

select a, b from t where a in (select c, d from t2)
select a, b from t where a in (select c, d from t2)

FIRST_ON_KEYWORD style — items aligned under first

select a, b, c from t
select a, b, c from t

FIRST_ON_KEYWORD with leading comma

select a, b, c from t
select a, b, c from t

FIRST_ON_KEYWORD with subquery

select a, b from t where a in (select c, d from t2)
select a, b from t where a in (select c, d from t2)

INLINE style — all on one line

select a, b, c from t
select a, b, c from t

BODY style — explicit (same as always)

select a, b, c from t
select a, b, c from t

GROUP BY STACKED

select a, b from t group by a, b
select a, b from t group by a, b

GROUP BY FIRST_ON_KEYWORD

select a, b from t group by a, b
select a, b from t group by a, b

ORDER BY STACKED

select a from t order by a, b desc
select a from t order by a, b desc

ORDER BY FIRST_ON_KEYWORD

select a from t order by a, b desc
select a from t order by a, b desc

ADAPTIVE SELECT items: preserves 3-per-line grouping

When WIDTH_AWARE (via ADAPTIVE) decides to break, it detects and preserves the user's original items-per-line grouping pattern.

select a, b, c,
d, e, f,
g from t
select a, b, c, d, e, f, g
from t

ADAPTIVE GROUP BY: preserves 3-per-line grouping

select a from t group by a, b, c,
d, e, f,
g
select a
from t
group by a, b, c, d, e, f, g

ADAPTIVE ORDER BY: preserves 2-per-line grouping

select a from t order by alpha, bravo,
charlie, delta,
echo
select a
from t
order by
alpha, bravo, charlie, delta, echo