Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>IndentFixNew to Visual Studio Code? Get it now.
IndentFix

IndentFix

Gaurav Tupe

|
2 installs
| (0) | Free
Fix indentation via context menu with formatter-first strategy and heuristic fallback.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

IndentFix — VS Code Extension

IndentFix is a VS Code extension that fixes indentation errors via a right-click context menu. It implements a "formatter-first" strategy with a heuristic reindenter fallback, following the PRD requirements.

Features

  • ✅ Context menu command: "IndentFix: Fix Indentation" appears in the editor right-click menu
  • ✅ Formatter-first workflow: Attempts to use VS Code's formatDocument command first
  • ✅ Heuristic reindenter fallback: Language-aware reindentation when formatters are unavailable
  • ✅ Safe edit semantics: Single undo step for all changes
  • ✅ Run-on-save: Optional automatic indentation fixing on save (opt-in)
  • ✅ File size checks: Automatically skips files larger than 1MB
  • ✅ Large change warnings: Prompts user for confirmation when >100 lines would change
  • ✅ Backup option: Can create backup untitled file before applying large changes
  • ✅ Configurable settings: Indent size, tabs vs spaces, language whitelist, formatter preferences

Supported Languages

  • Python
  • JavaScript/TypeScript (including JSX/TSX)
  • Java, C/C++, C#
  • JSON, HTML, CSS, XML

Quick Start

  1. Install dependencies:

    npm install
    
  2. Build the extension:

    npm run build
    
  3. Run in Development:

    • Press F5 in VS Code to open a new Extension Development Host
    • Right-click in any editor and select "IndentFix: Fix Indentation"

Configuration

Open VS Code settings and search for "IndentFix" to configure:

  • indentfix.indentSize: Number of spaces per indent level (default: 4)
  • indentfix.useTabs: Use tabs instead of spaces (default: false)
  • indentfix.runOnSave: Automatically fix indentation on save (default: false)
  • indentfix.languagesWhitelist: List of language IDs for run-on-save (default: python, javascript, typescript, json, html, css)
  • indentfix.preferredFormatterPerLanguage: Map languageId to preferred formatter (optional)

Usage

  1. Manual Fix: Right-click in the editor → "IndentFix: Fix Indentation"
  2. Automatic Fix: Enable indentfix.runOnSave in settings for automatic fixing on save

How It Works

  1. Formatter-first: Tries VS Code's editor.action.formatDocument command
  2. Fallback: If formatter fails or doesn't change the file, uses language-aware heuristic reindenter
  3. Safety: For large changes (>100 lines), prompts user with options:
    • Cancel
    • Backup + Apply (creates untitled backup file)
    • Apply

Implementation Details

  • Single undo step: All changes applied as one WorkspaceEdit
  • Language-aware: Different heuristics for brace languages (JS/TS/Java) vs Python-like languages
  • String/comment aware: Avoids modifying lines inside multi-line strings and comments
  • File size limits: Automatically skips files > 1MB

See Also

  • Full product requirements: docs/prd.text
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft