Skip to content

Formatting

Don Jayamanne edited this page Feb 15, 2016 · 6 revisions

#Formatting

###Default Formatter Code formatting is supported using either one of yapf or autopep8.
The default code format provider is autopep8.

Paths All samples provided here are for windows.
However Mac/Linux paths are also supported.

###AutoPep8 You can configure the format provider by changing a setting in the User or Workspace settings file as follows:

"python.formatting.provider": "autopep8"

Installing autopep8

pip install pep8   
pip install --upgrade autopep8

Custom Path It is assumed that the path to autopep8 is set in the current path.
If this is not the case or you wish to use another version of autopep8, all you need to do is configure the path as follows either in the User or Workspace settings file:

"python.formatting.autopep8Path": "c:/path/autopep8.exe"

###Yapf You can configure the format provider by changing a setting in the User or Workspace settings file as follows:

"python.formatting.provider": "yapf"

Custom Path It is assumed that the path to yapf is set in the current path.
If this is not the case or you wish to use another version of yapf, all you need to do is configure the path as follows either in the User or Workspace settings file:

"python.formatting.yapfPath": "c:/yapfPath/yapf.exe"

Installing Yapf pip install yapf

Clone this wiki locally