Skip to content

Instantly share code, notes, and snippets.

@matthiasr
Created May 11, 2023 09:32
Show Gist options
  • Save matthiasr/43d7cf45e54c9c7e43361a599f810073 to your computer and use it in GitHub Desktop.
Save matthiasr/43d7cf45e54c9c7e43361a599f810073 to your computer and use it in GitHub Desktop.
Configuring Format on Save for Terraform in VS Code

If VS Code does not format Terraform code on save, but does format correctly when ask explicitly (Command palette -> Format File), add this to the configuration JSON:

    "[terraform]": {
        "editor.defaultFormatter": "hashicorp.terraform",
        "editor.formatOnSave": true
    }

source

The trick here is that we configure the global format-on-save but only for terraform files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment