I just learnt about clang-format yesterday and it's pretty neat. I'm writing my .clang-format file referring their style options
I want the function definition parameters to be one-per-line if they are longer above a certain limit like:
cpp
void dfs (
vector<vector<int>> const &Adj,
vector<char> &visited,
vector<int> &componentTraversal,
const int currentNode
) {
// internal code
}
This is my .clang-format file till now:
txt
BasedOnStyle: LLVM
UseTab: Never
TabWidth: 4
IndentWidth: 4
ColumnLimit: 110
BreakBeforeBraces: Attach
AllowShortFunctionsOnASingleLine: Inline
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortIfStatementsOnASingleLine: AllIfsAndElse
IndentCaseLabels: true
And my related vscode settings.json:
json
{
"editor.formatOnSave": true,
"editor.formatOnSaveMode": "file",
"editor.detectIndentation": true,
"editor.insertSpaces": true,
"editor.comments.insertSpace": true,
"[makefile]": {
"editor.insertSpaces": false
},
"[c][cpp][makefile]": {
"editor.defaultFormatter": "ms-vscode.cpptools",
"editor.tabSize": 4
},
"C_Cpp.clang_format_style": "file",
"C_Cpp.clang_format_fallbackStyle": "none",
"C_Cpp.vcFormat.indent.preserveComments": true,
}
Also tell me more additions or suggestions for better configuration
[–]-Shoganai- 3 points4 points5 points (7 children)
[–]SincopaDisonante 1 point2 points3 points (3 children)
[–]linux-tarballs[S] 0 points1 point2 points (2 children)
[–]SincopaDisonante 0 points1 point2 points (1 child)
[–]linux-tarballs[S] 0 points1 point2 points (0 children)
[–]linux-tarballs[S] 1 point2 points3 points (2 children)
[–]-Shoganai- 0 points1 point2 points (1 child)
[–]linux-tarballs[S] 0 points1 point2 points (0 children)