ktfmtter
A VS Code extension that runs ktfmt to format Kotlin code.
This project is based on the original vscode-ktfmt extension by Christopher Drost, with added support for selecting the formatting style.
Copyright © 2025-present Shape
Features
This is a fork of vscode-ktfmt, with added support for selecting a formatting style.
When activated, the extension prompts you to choose a ktfmt version, which will then be downloaded and cached.
- You can set
ktfmt as the default formatter for Kotlin files by adding the following to your settings.json file:
{
// The version of ktfmt to use.
// This is updated automatically when you select a version from the prompt.
// Set this to `null` to be prompted to select a version again.
"ktfmtter.ktfmtVersion": "0.47",
// Optional: Set the formatting style. Can be 'kotlinlang' or 'google'.
"ktfmtter.style": "kotlinlang",
// Optional: Specify which Java runtime to use.
// If not set, it will use the one marked as default in 'java.configuration.runtimes'.
"ktfmtter.java-runtime": "JavaSE-17",
"[kotlin]": {
"editor.defaultFormatter": "shape-app.ktfmtter"
}
}
- This extension uses your Java configuration to run
ktfmt. It assumes you have the Java Language Support extension installed, which sets up an array of runtimes at java.configuration.runtimes. If you haven’t configured this yet, you may need to add something like the following to your settings.json:
{
"java.configuration.runtimes": [
{
"name": "JavaSE-17",
"path": "/path/to/your/java/home",
"default": true
}
]
}
- If you don't want to use the
default runtime to run ktfmt, copy the name property into ktfmtter.java-runtime and this extension will use that path instead.
Attribution
This project is based on the original work:
- vscode-ktfmt: Copyright (c) 2020-2023 Christopher Drost - GitHub
Third-party components:
- ktfmt: Copyright (c) Facebook, Inc. and its affiliates - GitHub
- VS Code Extension API: Copyright (c) Microsoft Corporation
Release Notes
1.1.1
- Added extension icon.
- Updated extension description.
1.1.0
- Added
ktfmtter.selectVersion command to download and select ktfmt version.
1.0.0
- Initial fork of
crdrost/vscode-ktfmt.
- Added
ktfmtter.style setting.