I recently installed yapf using pip and configured the settings.json file of vscode but I don't know how to run yapf formatting the current opened file on save. Any clue?
here is my settings.json
file:
"[python]": {
"editor.defaultFormatter": "ms-python.python",
"editor.tabSize": 4,
"editor.insertSpaces": true,
"editor.formatOnSave": true,
"editor.formatOnSaveMode": "modifications",
"editor.formatOnType": true,
"editor.formatOnPaste": true,
},
"python.formatting.provider": "yapf",
"python.formatting.yapfPath": "/usr/local/bin/yapf",
"python.linting.lintOnSave": true,
"python.linting.enabled": true,
"python.defaultInterpreterPath": "python3",
Here is my .style.yapf
file:
[style]
based_on_style = google
spaces_before_comment = 4
indent_width: 2
split_before_logical_operator = true
column_limit = 180
I am using:
- Mac OS 11.6.1.
- VS Code 1.64.0