0

When I type the python code in vs code, indent tab size is 2. But when I save the file, tab size is changed to 4. I think this is because of autopep8.

How can I change the tab size, when I save the python code?

※ I already change editor.tabsize to 2

1
  • Do you see a tab button in the lower right corner? Commented Jun 29, 2020 at 8:49

2 Answers 2

2

It's recommended to set '--indent-size' to change the autopep8 behavior. You can refer to this page for details. But I can't make it works in this way, so I directly make a change in autopep8.py(under site-packages which you installed the autopep8) file, at the line of 112 change "DEFAULT_INDENT_SIZE = 4" to "DEFAULT_INDENT_SIZE = 2". It works and it's the same to set '--indent-size' in logic.

Sign up to request clarification or add additional context in comments.

Comments

0

You will need to configure autopep8 to keep indent to two spaces. That way it won't undo how VS Code is inserting spaces for you.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.