I noticed one strange thing that autopep8 autoformatting in VSCode doesn't work when we set
"python.formatting.autopep8Args": [
"--line-length 119"
],
But if this setting is in a default mode that is line length 79 then it works well. Is there some issue with autopep8 to work only with line length 79 not more than that, or I am making any mistake in VSCode. Major feature that I need is when my python program line goes too long it should be able to break it in multiple lines. I don't want to go ahead with 79 characters' approach. My preferred approach is 119 characters. Currently, I have to indent big lines manually. Is there any other format apart from pep8 which supports 119 characters and indent lines with characters more than 119 characters automatically.
I am attaching my settings.json file data
{
"window.zoomLevel": 1,
"python.dataScience.sendSelectionToInteractiveWindow": true,
"diffEditor.ignoreTrimWhitespace": false,
"editor.fontSize": 16,
"python.formatting.provider": "autopep8",
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
"editor.formatOnType": true,
"python.autoComplete.addBrackets": true,
"python.formatting.autopep8Args": [
"--line-length 119"
],
// "python.linting.flake8Args": [
// "--max-line-length=120"
// ],
"files.autoSaveDelay": 10000,
"editor.defaultFormatter": "ms-python.python",
"files.autoSave": "afterDelay",
"files.trimTrailingWhitespace": true,
"files.trimFinalNewlines": true,
"editor.quickSuggestions": true,
"editor.codeActionsOnSave": null,
}
experimental worked for me
"python.formatting.autopep8Args": ["--max-line-length", "120", "--experimental"]
check out this link for proper format specifier settings
This should work -
"python.formatting.provider": "autopep8",
"python.formatting.autopep8Args": [
"--max-line-length",
"120",
"--experimental"
]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With