This lets you have consistently formatted code with no additional effort (manual labor of fixing it yourself, adding commit hooks, or running a formatter from the command line.) I use the black
code-formatter, but you could find another one.
- Install
black
in whatever python interpreter you are using for visual studio code:pip install black
. - Navigate: Preferences --> Settings.
- Find and set: Format provider -->
black
. - Open settings.json by finding
"edit settings.json in the settings pane"
. Just scroll around and you'll find it. - Add a line:
"editor.formatOnSave": true
.