A Godot Editor (4.x) addon for formatting GDScript automatically.
- Format with shortcut
- Defaults to Shift+Alt+F
- Format on save
- Off by default, can be enabled by editing the preferences file
- Format through tool menu
- Project -> Tool -> GDScript Formatter: Format script
- Format through command palette
- Open the command palette (Default Ctrl+Shift+P) and run command
Format GDScript
- Open the command palette (Default Ctrl+Shift+P) and run command
GDScript Formatter relies on GDToolkit which uses Python and Pip package manager. You need to install them in order to use the addon.
- Install Python (if you do not have it already)
- Download installer from [https://www.python.org/downloads/]
- Make sure to enable "Add python.exe to PATH" when installing
- If you forget you can add python.exe to PATH after installation
- Pip is included with python
- Install the Godot plugin
- In Godot editor, click "AssetLib" and search "GDScript Formatter"
- Install the plugin
- Enable the plugin through Project -> Project Settings -> Plugins
- Install GDToolkit
- Project -> Tool -> GDScript Formatter: Install/Update gdtoolkit
You can edit GDScript Formatter's behavior through the preferences file. Preferences are stored as a Godot resource located in res://addons/gdscript_formatter/format_preference.tres
. Double click the file from Godot and you can change whether files are formatted on save, the gdformat command, line length, and other values.