vscode python 在保存文件时自动将缩进格式设置为 2 个空格而不是 4 个空格

问题描述 投票:0回答:1

如何使我的 python 源代码在单击保存文件时强制使用 2 个空格缩进。生成的 ChatGPT 代码总是产生 4 个空格,这就是我问这个的原因。我对 python 中的 4 个空格缩进感到不舒服。我尝试了 autopep8 格式化程序扩展,但它没有帮助我。

这是我现在的

.vscode/settings.json

{
  "editor.tabSize": 2,
  "editor.defaultFormatter": "ms-python.autopep8",
  "editor.insertSpaces": true,
  "autopep8.args": [
    "--indent-size=2"
  ]
}
python visual-studio-code indentation auto-indent
1个回答
0
投票

如果您想更改表格中的空格数,请转到设置(使用 Ctrl + 或首选项

© www.soinside.com 2019 - 2024. All rights reserved.