
A robust, whitespace-aware formatter for Paradox Interactive game scripts (Stellaris, HOI4, EU4, CK3).
This extension provides smart indentation, block expansion, and syntax protection, ensuring your code looks clean without breaking game logic or deleting comments.
✨ Features
1. Smart Block Expansion
Automatically expands one-line blocks into readable, multi-line structures, which is crucial for complex scope logic.
Before:
NOR = { has_star_flag = marauder_starbase_destroyed has_star_flag = starbase_destroyed }
After:
NOR = {
has_star_flag = marauder_starbase_destroyed
has_star_flag = starbase_destroyed
}
2. Code Protection Logic
Unlike other formatters that delete code context, this formatter treats your code as text, preserving crucial elements:
- Preserves Comments:
# Comments are protected and restored exactly where they were.
- Preserves Strings: Strings like
name = "don't split { here }" are safe from accidental formatting.
Allows formatting of just a specific block of code without touching the rest of the file.
- Shortcut:
Ctrl + K, Ctrl + F (or Cmd + K, Cmd + F on Mac)
🚀 Installation
Manual Installation (.vsix)
You can install the packaged extension directly using the .vsix file.
- Download the
paradox-script-formatter-0.2.0.vsix file.
- Open VS Code.
- Go to the Extensions View (
Ctrl+Shift+X).
- Click the three dots icon (...) at the top-right of the Extensions menu.
- Select "Install from VSIX...".
- Locate and select the
paradox-script-formatter-0.2.0.vsix file.
Alternatively, you can install it via the command line:
code --install-extension paradox-script-formatter-0.2.0.vsix
Supported File Types
Automatically activates for:
.txt (Paradox Script)
.gui (Interface Files)
- Language IDs:
paradox, stellaris
⚙️ Configuration
To ensure this formatter is used automatically when you save a file, you need to set it as the default formatter for the Paradox language.
- Open your Settings (
Ctrl + ,).
- Search for
default formatter.
- You can set the formatter globally or specifically for Paradox files in your
settings.json:
{
// Sets the Paradox Formatter as the default for all languages where it applies
"editor.defaultFormatter": "f1r3pr1nc3.paradox-script-formatter",
// Recommended: Set preferred indentation style (if not using .editorconfig)
"editor.insertSpaces": false, // Use tabs
"editor.tabSize": 4
}
🤝 Contributing
Contributions are welcome! If you find a case where the formatter breaks a specific script structure, please open an issue with a code snippet.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature)
- Commit your Changes (
git commit -m 'Add some AmazingFeature')
- Push to the Branch (
git push origin feature/AmazingFeature)
- Open a Pull Request
📜 License
Distributed under the MIT License. See LICENSE for more information.