
This is a maintained fork of foxundermoon/vs-shell-format. It downloads shfmt from GitHub and checks a checksum. In an untrusted workspace, the workspace cannot set shellformat.path or shellformat.flag. See https://github.com/foxundermoon/vs-shell-format/issues/396.
Supported file types or languages
| language |
extension |
description |
| shellscript |
.sh .bash, bash dotfiles, PKGBUILD, APKBUILD, *.ebuild, *.eclass |
shell script files |
| dockerfile |
Dockerfile, Dockerfile.*, *.dockerfile |
dockerfile |
| dotenv |
.env .env.* env |
dotenv files |
| ignore |
.gitignore .dockerignore |
ignore files |
| properties |
.properties (also spring-boot-properties) |
java properties files |
| jvmoptions |
.vmoptions , jvm.options |
jvm options file |
| hosts |
hosts |
hosts file |
| azcli |
.azcli |
Azure CLI script files |
| bats |
.bats |
Bats test file |
| zsh |
.zsh .zshrc .zshenv .zprofile .zlogin .zlogout |
zsh script files |
| mksh |
.mksh .mkshrc |
mksh script files |
| dash |
.dash |
dash / posix shell |
Shell files use shfmt. Dockerfiles use dockerfmt.

Usage
shift+alt+f (Windows/Linux) or shift+option+f (Mac)
ctrl+shift+p (Windows/Linux) or command+shift+p (Mac), then type Format Document
shfmt download
On first use, the extension downloads shfmt v3.14.1 from GitHub releases. The version is pinned in src/config.ts. Each download is checked against a SHA-256 checksum.
The binary is stored in the extension folder:
<extension>/bin/shfmt_v3.14.1_<os>_<arch>
Examples: shfmt_v3.14.1_linux_amd64, shfmt_v3.14.1_darwin_arm64, shfmt_v3.14.1_windows_amd64.exe.
Windows ARM64 has no official shfmt build. Set shellformat.path to a binary you provide.
The extension starts without waiting for that download. The first format waits until the download finishes. If the download fails, set shellformat.path.
Offline or manual install
You can skip the download:
- Get shfmt v3.14.1 from mvdan/sh releases.
- Put the file in the extension
bin/ folder.
- Use the platform name from
src/config.ts, for example shfmt_v3.14.1_linux_amd64.
Or set shellformat.path to a shfmt binary you already have. That setting is user only. A workspace cannot set it.
Only the GitHub auto-download is checksummed. A custom shellformat.path is not.
EditorConfig
Set shellformat.useEditorConfig to true to apply .editorconfig. The extension reads that file and turns keys into shfmt flags: -i, -ln, -bn, -ci, -sr, -kp, -fn. When that setting is on, shellformat.flag is ignored.
Untitled files have no path, so EditorConfig may be empty. The editor tab size still applies in that case.
When the setting is off, shellformat.flag and the editor tab size apply.
Sample .editorconfig:
[*.sh]
indent_style = space
indent_size = 2
shell_variant = posix
binary_next_line = true
switch_case_indent = true
Settings
shellformat.path: full path to shfmt. User setting only. Example on macOS or Linux: /usr/local/bin/shfmt. Example on Windows: C:\bin\shfmt.exe. This path is not checksummed.
shellformat.flag: extra shfmt flags, for example -p -bn -ci. User setting only. Ignored when shellformat.useEditorConfig is on. Do not use -w.
shellformat.effectLanguages: languages this formatter runs on. Default is all supported languages.
shellformat.useEditorConfig: when on, apply .editorconfig. shellformat.flag is ignored.
Troubleshooting
- The formatter does nothing: check
shellformat.effectLanguages. Also open the shellformat output channel.
- shfmt is missing: set
shellformat.path.
- A red squiggle at
line:col: shfmt found a parse error at that place.
Privacy
This extension does not send telemetry. The only network call is the shfmt download from GitHub releases.
Contributors of the original project
Code Contributors
This project exists thanks to all the people who contribute.
