Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Code and Autopep8 Formatter

I am trying to setup my python formatter to autopep8. It is installed properly, however it never as a formatting option in VSCode.

"python.formatting.autopep8Path": "C:\\Users\\DawsonSchaffer\\AppData\\Roaming\\Python\\Python39\\Scripts\\autopep8.exe",
    "python.formatting.autopep8Args": [
        "--max-line-length",
        "160",
        "--aggressive",
        "--aggressive",
        "--in-place"
    ],
    "[python]": {
        "editor.defaultFormatter": "autopep8",
    },

enter image description here

I have changed all the setting. However I'm not sure what to put for autopep8.

"[python]": {
    "editor.defaultFormatter": "ms-python.python",
},

or

"[python]": {
    "editor.defaultFormatter": "autopep8",
},

Also autopep8 is not available in control pallet.

enter image description here

Thanks Dawson

like image 898
DawsonMSchaffer Avatar asked Apr 02 '26 11:04

DawsonMSchaffer


1 Answers

This is to configure the

  "[python]": {
    "editor.defaultFormatter": "ms-python.python"
  },

in the settings.json.

You can set like this to apply autopep8 formatting:

"python.formatting.provider": "autopep8",
"editor.formatOnSave": true,
"files.autoSave": "afterDelay",

Related official docs.

like image 106
Steven-MSFT Avatar answered Apr 23 '26 20:04

Steven-MSFT