Skip to main content

Indent width

indentWidth is the number of spaces one level of nesting adds. A clause body stacked beneath its keyword, a subquery inside its parentheses, the continuation of an expression that broke: each is one level in, and all of them move together when you change it.

Default: 4. Two levels are still visibly two at a glance, and a subquery three levels deep still leaves most of an 80-column line for its text. It is also what the dbt style guide and most SQL style guides use.

Set 2 for a project that already indents its SQL that way, so that the first format does not touch every indented line. The range is 1 to 8.

The same statement at 4 and at 2​

select a, b from t where x in (select y from u where z = 1 and w = 2) and long_column_name = 'a long value here'
select a, b
from t
where
    x in (
        select y
        from u
        where z = 1 and w = 2
    )
    and long_column_name
        = 'a long value here'
select a, b from t where x in (select y from u where z = 1 and w = 2) and long_column_name = 'a long value here'
select a, b
from t
where
  x in (
    select y
    from u
    where z = 1 and w = 2
  )
  and long_column_name
    = 'a long value here'