如何在 VSCode 和 Intellij 中设置相同的 Terraform 格式样式

How to set up the same Terraform formatting style in VSCode and Intellij

我正在 VSCode 中设置环境以开发 Terraform。

我正在与另一位使用 Intellij 的开发人员合作,我使用 VSCode。

enter image description here

左边红色部分是用Intellij写的代码,右边绿色部分是用VSCode写的代码。

我想将ESLint设置成彼此相同,以设置一致的格式。我该怎么做?

而且我已经设置好了setting.json

enter image description here

现在我使用扩展

HashiCorp Terraform https://marketplace.visualstudio.com/items?itemName=HashiCorp.terraform

Terraform(分叉) https://marketplace.visualstudio.com/items?itemName=l2fprod.terraform-fork

非常感谢。

terraform fmt 命令用于将 Terraform 配置文件重写为规范格式和样式。此命令应用 Terraform 语言样式约定的子集,以及其他可读性的小调整。

https://www.terraform.io/cli/commands/fmt

与其更改 IDE 中的格式,您应该 运行 terraform fmt 命令,它将格式化您的代码以更正格式。