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
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 yoursettings.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 atjava.configuration.runtimes
. If you haven’t configured this yet, you may need to add something like the following to yoursettings.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 runktfmt
, copy thename
property intoktfmtter.java-runtime
and this extension will use thatpath
instead.
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
Nothing right now.
- Added extension icon.
- Updated extension description.
- Added
ktfmtter.selectVersion
command to download and selectktfmt
version.
- Initial fork of
crdrost/vscode-ktfmt
. - Added
ktfmtter.style
setting.