Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable auto-indentation of Python function arguments in VS Code

I'm looking to enable automatic indentation of Python function arguments, as shown in the example below generated with use of pycharm. I had a look at a similar discussion but the discussed solutions do not appear to solve this problem.

Desired Behaviour

PyCharm

VS Code

VS Code indentation


  • VS Code version: 1.27.2
  • Python extension: 2018.8.0 (04 September 2018)

Update

  • Current autoIndent setting enter image description here
like image 579
Konrad Avatar asked Sep 16 '18 10:09

Konrad


People also ask

How do you indent Python code in Visual Studio code?

indent a whole block manually: select the whole block, and then click Tab . If you want to indent backward, you do it with Shift + Tab .

How do I set auto indentation in Python?

Auto-indent can be disabled with the Editor > Indentation > Auto-indent preference. When disabled, the Tab key may be used to insert indentation, depending on its configuration. Wing also auto-indents code when pasting multiple lines of Python.


1 Answers

This is a known issue for the Python VSCode extension and it can currently not be fixed because of limitations in the extension API. More specifically the line in the editor cannot know the content of other lines. I am not aware of any fix for this issue, but I agree that it decreases the experience of working with VSCode by far.

See this issue for further information: https://github.com/Microsoft/vscode-python/issues/701

like image 130
larsl Avatar answered Oct 11 '22 03:10

larsl