Max Line Width
When maxLineWidth is set with WIDTH_AWARE / ADAPTIVE modes, constructs exceeding a width threshold are broken to vertical layout.
Default: maxLineWidth=0 (disabled) — width-based breaking is off, WIDTH_AWARE / ADAPTIVE falls back to trivia detection only.
With value: When set (e.g., 80), WIDTH_AWARE / ADAPTIVE mode measures the relevant construct and breaks it if it exceeds a threshold:
| Construct | What is measured | Threshold | "Chop down" behavior |
|---|---|---|---|
| SELECT/GROUP BY/ORDER BY items | The item list (excluding keyword) | maxLineWidth - keyword.length | All items go vertical |
| Function args | The argument list | maxLineWidth - keyword.length | All args go vertical |
| CASE WHEN | The entire CASE expression | maxLineWidth / 2 | WHEN/ELSE get newlines |
| AND/OR in WHERE/HAVING/ON | The enclosing condition expression | maxLineWidth / 2 | All AND/OR get newlines |
AND/OR suppression in CASE WHEN: AND/OR inside CASE WHEN conditions are never broken by width — the CASE formatting handles the overall layout.
Explicit modes override: ALWAYS and NEVER modes ignore maxLineWidth entirely. Only WIDTH_AWARE / ADAPTIVE uses it.
SELECT fits within max width
Short SELECT list fits within maxLineWidth — stays compact.
select a, b from t
select a, b from t
SELECT exceeds max width
Long SELECT list exceeds maxLineWidth — breaks to vertical.
select very_long_column_a, very_long_column_b, very_long_column_c from t
select
very_long_column_a,
very_long_column_b,
very_long_column_c
from t
Max width disabled preserves user layout
maxLineWidth=0 (disabled) — falls back to trivia detection (user wrote compact).
select very_long_column_a, very_long_column_b, very_long_column_c from t
select
very_long_column_a, very_long_column_b, very_long_column_c
from t
GROUP BY exceeds max width
select a from t group by very_long_col_a, very_long_col_b, very_long_col_c
select a
from t
group by
very_long_col_a, very_long_col_b,
very_long_col_c
Function args exceed max width
select coalesce(very_long_expr_a, very_long_expr_b, very_long_expr_c) from t
select
coalesce(
very_long_expr_a, very_long_expr_b,
very_long_expr_c
)
from t
Function args fit within max width
Short function args fit within maxLineWidth — stays compact.
select coalesce(a, b) from t
select coalesce(a, b) from t
ALWAYS overrides max width
ALWAYS mode ignores maxLineWidth — always breaks even if fits.
select a, b from t
select a, b from t
NEVER overrides max width
NEVER mode ignores maxLineWidth — never breaks even if exceeds.
select very_long_column_a, very_long_column_b, very_long_column_c from t
select
very_long_column_a,
very_long_column_b,
very_long_column_c
from t
AND/OR fits within max width
Short WHERE condition fits within maxLineWidth — stays compact.
select a from t where x > 1 and y > 2
select a from t where x > 1 and y > 2
AND/OR exceeds max width
Long WHERE condition exceeds maxLineWidth — breaks AND/OR to vertical.
select a from t where very_long_column_name > 100 and another_long_column > 200 and third_column > 300
select a
from t
where
very_long_column_name > 100
and another_long_column > 200
and third_column > 300
AND/OR in JOIN ON exceeds max width
select a from t1 inner join t2 on t1.very_long_id = t2.very_long_id and t1.another_col = t2.another_col
select a
from t1
inner join t2
on
t1.very_long_id = t2.very_long_id
and t1.another_col = t2.another_col
AND/OR in HAVING exceeds max width
select a, count(*) from t group by a having count(*) > 10 and sum(very_long_column_name) > 1000
select a, count(*)
from t
group by a
having
count(*) > 10
and sum(very_long_column_name) > 1000
AND/OR inside CASE WHEN suppressed
AND/OR inside CASE WHEN conditions should not break even when maxLineWidth is set.
select case when a > 1 and b > 2 then 'yes' else 'no' end from t
select
case
when a > 1 and b > 2 then 'yes'
else 'no'
end
from t
Long arithmetic chain with max width
select total_amount * discount_rate + tax_amount - refund_amount + adjustment_value from orders
select
total_amount * discount_rate + tax_amount - refund_amount + adjustment_value
from orders
CASE WHEN exceeds max width
When a WHEN clause body exceeds maxLineWidth, the THEN keyword breaks to a new indented line.
select case when very_long_column > 100 then 'yes' else 'no' end from t
select
case
when very_long_column > 100
then 'yes'
else 'no'
end
from t