Skip to main content
  • Created:
  • Updated:
  • Author:
    Takeshi Takatsudo

autoDetectIndent

Automatically detect indentation style (spaces vs tabs, indent size) from the file content and apply it consistently across all formatting rules.

Disabled by default. When enabled, detected indentation overrides indentSize settings in other rules.

Options

PropertyTypeDefaultDescription
enabledbooleanfalseEnable/disable auto-detection
fallbackIndentSizenumber2Default indent size if detection fails
fallbackIndentTypestring"space"Default indent type: "space" or "tab"
minConfidencenumber0.7Minimum confidence score (0-1) to use detected indentation

Config

{
"autoDetectIndent": {
"enabled": true,
"fallbackIndentSize": 2,
"fallbackIndentType": "space",
"minConfidence": 0.7
}
}

Examples

4-space indentation detected

If a file primarily uses 4-space indentation, the formatter preserves it:

Before:

<Component
propA="value1"
propB="value2"
propC="value3" />

After (detected 4-space indent):

<Component
propA="value1"
propB="value2"
propC="value3" />

Tab indentation detected

If a file uses tabs, HTML block formatting also uses tabs:

Before:

<dl>
<dt>Term</dt>
<dd>Definition</dd>
</dl>

After (detected tab indent):

<dl>
<dt>Term</dt>
<dd>Definition</dd>
</dl>

Fallback when detection fails

If the file has no clear indentation pattern, the fallbackIndentSize and fallbackIndentType values are used (default: 2 spaces).