Should I stop using a code formatter (such as Prettier in VScode)?
visual studio code - Problem formatting python when using Prettier in vscode - Stack Overflow
My prettier code is not working!
Curious, why should one use Prettier for code formatting?
Videos
I’ve been doing an internship lately, and have been using Prettier code formatter in my editor.
Often when I make just a small change to their code base there ends up being hundreds of other lines which get changed as well due to Prettier.
Then in GitHub, instead of seeing the one small change, there are many changes... even after excluding white space.
I can imagine this would make things more difficult for the code reviewer.
Should I just disable Prettier? Or at least disable things like line-wrapping, etc.?
If I disabled Prettier as the default formatter, it would not format on save anymore, but my Python would be formatted by autopep8 on save. With this in mind, the following solution worked for me to have both Prettier working for other languages and autopep8 for Python:
{
"workbench.iconTheme": "vscode-icons",
"workbench.editorAssociations": [
{
"viewType": "jupyter.notebook.ipynb",
"filenamePattern": "*.ipynb"
}
],
"git.confirmSync": false,
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
"python.formatting.provider": "autopep8",
"explorer.confirmDelete": false,
"python.showStartPage": false,
"explorer.confirmDragAndDrop": false,
"python.linting.pylintArgs": ["--load-plugins=pylint_django"],
"javascript.updateImportsOnFileMove.enabled": "always",
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[python]": {
"editor.defaultFormatter": "ms-python.python"
}
}
Let me know if somebody finds a better solution!
Meaningful config snippet from @round_circle's answer:
"[python]": {
"editor.defaultFormatter": "ms-python.python"
}
After adding it, autopep8 worked for python files.