Published on

VSCode Python Formatting with Black

Authors
    avatar

    John Partee

In VSCode, open your settings.json (Control+Shift+P, enter 'open settings json', hit enter), and paste this in to enable black formatting on save.

json

  "python.formatting.provider": "black",
  "editor.formatOnSave": true,

Make sure you have it installed too.

bash

# From the command line:
pip install black

Find this useful? I have more VSCode sensible defaults here

This is a part of a series of quick defaults to make your life easier, based on how we show up in search results.

While you're in there, add autosaving and auto linting too. It's handy.

py

  "python.linting.enabled": true,
  "files.autoSave": "afterDelay",
  "files.autoSaveDelay": 10000,
  "python.linting.lintOnSave": true

Happy coding!

Want an email when we post?

Free, weekly at most. We hate spam too.