Skip to main content

Opt-Out Comments

Format control comments that allow preserving original SQL in specific regions.

Directives:

  • -- fmt:off / -- fmt:on — region-based skip (everything between is preserved verbatim)
  • -- fmt:ignore — skip next statement only
  • Block comment variants: /* fmt:off */, /* fmt:on */

Behavior: fmt:off without matching fmt:on disables formatting for the rest of the file. fmt:ignore applies to exactly one statement.

fmt:off and fmt:on region

Statements between fmt:off and fmt:on are preserved verbatim.

select a from t;
-- fmt:off
select b from t2;
-- fmt:on
select c from t3
select a from t;

-- fmt:off
select b from t2;
-- fmt:on

select c from t3

fmt:ignore skips next statement

fmt:ignore skips only the next statement.

select a from t;
-- fmt:ignore
select b from t2;
select c from t3
select a from t;

-- fmt:ignore
select b from t2;

select c from t3

fmt:off without fmt:on

fmt:off without matching fmt:on disables formatting for rest of file.

select a from t;
-- fmt:off
select b from t2;
select c from t3
select a from t;

-- fmt:off
select b from t2;
select c from t3

Multiple fmt:off/on regions

Multiple regions can be toggled.

select a from t;
-- fmt:off
select b from t2;
-- fmt:on
select c from t3;
-- fmt:off
select d from t4
select a from t;

-- fmt:off
select b from t2;
-- fmt:on

select c from t3;

-- fmt:off
select d from t4

No control comments (baseline)

Without control comments, everything is formatted normally.

select a from t;
select b from t2
select a from t;

select b from t2

fmt:ignore with single statement file

fmt:ignore on a single-statement file.

-- fmt:ignore
select a from t
-- fmt:ignore
select a from t

fmt:off at start of file

fmt:off at the very beginning.

-- fmt:off
select a from t;
select b from t2
-- fmt:off
select a from t;
select b from t2

Block comment fmt:off

Block comment style also works.

select a from t;
/* fmt:off */
select b from t2;
/* fmt:on */
select c from t3
select a from t;

/* fmt:off */
select b from t2;
/* fmt:on */

select c from t3