简体   繁体   中英

Use tabs instead of space in VSCode when writing Python?

How does one make the formatter in VSCode use tabs instead of spaces for indentation when programming in Python? I have already set VSCode to use tabs, but the formatter for Python ignores that and just does its own thing.

I've been trying to Google around, but I am only seeing results telling me how to do the opposite, ie. spaces instead of tabs, but that is not what I want. I tried to look at autopep8, which VSCode seems to be using for this formatting, but I can't find anything useful there, either.

You can use the editorconfig extension.

Create a .editorconfig at the root of the project and specify your configuration.

root = true

[*] # extensions of the files
indent_style = tab
indent_size = 2

Run format document after that and.. viola!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM