Auto formatting reduces the burden to clean up code and increases readability.
We recommend here formatters available for development with VSCode.
We use black formatter for formatting the python code.
To run the formatter:
# for formatting
pip3 install black
black --line-length 120 .
Get where black is installed:
python3 -c 'import black; from pathlib import Path; print(Path(black.__file__).parent)'
In VSCode CTRL
+Shift
+P
edit your settings.json
:
"editor.formatOnSave": true,
"python.formatting.blackPath": "~/.local/lib/python3.8/site-packages/black",
Install Clang-Format
Extension in VSCode.
Use the Google Formatting option.
Example .clang-format
file is provided at best-practices/formatting/.clang-format
.
Set as default in settings.json
:
"[cpp]": {
"editor.defaultFormatter": "xaver.clang-format"
},
Standard XML Language Support
by Red Hat Extension in VSCode.
Set as default in settings.json
:
"[xml]": {
"editor.defaultFormatter": "redhat.vscode-xml"
},
"xml.format.emptyElements": "collapse",
"xml.format.joinCDATALines": true,
Install Standard YAML Language Support
by Red Hat Extension in VSCode.
Set as default in settings.json
:
"[yaml]": {
"editor.defaultFormatter": "redhat.vscode-yaml"
}
Install cmake-format
Extension in VSCode.
Install using pip:
pip3 install cmake_format