编写Python时在VSCode中使用制表符而不是空格?

Wer*_*atf 5 python indentation visual-studio-code

在 Python 中编程时,如何让 VSCode 中的格式化程序使用制表符而不是空格进行缩进?我已经将 VSCode 设置为使用制表符,但 Python 的格式化程序会忽略这一点,只做自己的事情。

我一直在尝试谷歌搜索,但我只看到结果告诉我如何做相反的事情,即。空格而不是制表符,但这不是我想要的。我尝试查看 autopep8,VSCode 似乎正在使用 autopep8 来进行这种格式化,但我也找不到任何有用的东西。

小智 0

您可以使用 editorconfig 扩展。

.editorconfig在项目的根目录创建一个并指定您的配置。

root = true

[*] # extensions of the files
indent_style = tab
indent_size = 2
Run Code Online (Sandbox Code Playgroud)

追赶format document那然后..中提琴!