Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to setup vscode settings for Python formatter?

Somehow my formatter isn't working. I pip installed yapf , but when I do Ctrl+Shift+P -> Format Document or Shift + Alt + F on a selected code, It doesn't change. I heard it auto formats on save, but that didn't work either.

I am trying to follow the guide here. It mentions I should edit this part in the settings

"python.formatting.yapfArgs": ["--style", "{based_on_style: chromium, indent_width: 20}"],

But when I search this, this is the only thing I see

What I am trying to do at the moment is set the indent to 4 spaces, and also adjust the max line length.

This is what my settings look like for formatting

like image 445
SantoshGupta7 Avatar asked Oct 15 '25 04:10

SantoshGupta7


1 Answers

It seems in the preference you have not set the correct "provider" for the formatting

enter image description here

You can also check for the file C:\Users\\AppData\Roaming\Code\User\settings.json (if you want to change globally) or \.vscode\settings.json (if you want to change for the current workspace only).

enter image description here

Hope that helps.

like image 74
VarunG Avatar answered Oct 17 '25 16:10

VarunG



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!