Skip to content

Instantly share code, notes, and snippets.

@cjlovering
Created December 8, 2020 17:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cjlovering/acde6e3f01b152ba11d309a25601c913 to your computer and use it in GitHub Desktop.
Save cjlovering/acde6e3f01b152ba11d309a25601c913 to your computer and use it in GitHub Desktop.
Auto-format in visual studio code on save.

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.

  1. Install black in whatever python interpreter you are using for visual studio code: pip install black .
  2. Navigate: Preferences --> Settings.
  3. Find and set: Format provider --> black.
  4. Open settings.json by finding "edit settings.json in the settings pane". Just scroll around and you'll find it.
  5. Add a line: "editor.formatOnSave": true.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment