2020-10-24 13:40:29 +01:00
|
|
|
# clang-format
|
|
|
|
|
2024-02-14 20:25:13 +00:00
|
|
|
> Auto-format C/C++/Java/JavaScript/Objective-C/Protobuf/C# code.
|
2020-10-24 13:40:29 +01:00
|
|
|
> More information: <https://clang.llvm.org/docs/ClangFormat.html>.
|
|
|
|
|
2022-12-04 07:53:34 +00:00
|
|
|
- Format a file and print the result to `stdout`:
|
2020-10-24 13:40:29 +01:00
|
|
|
|
|
|
|
`clang-format {{path/to/file}}`
|
|
|
|
|
|
|
|
- Format a file in-place:
|
|
|
|
|
|
|
|
`clang-format -i {{path/to/file}}`
|
|
|
|
|
|
|
|
- Format a file using a predefined coding style:
|
|
|
|
|
2024-04-18 19:38:25 +01:00
|
|
|
`clang-format --style {{LLVM|GNU|Google|Chromium|Microsoft|Mozilla|WebKit}} {{path/to/file}}`
|
2020-10-24 13:40:29 +01:00
|
|
|
|
|
|
|
- Format a file using the `.clang-format` file in one of the parent directories of the source file:
|
|
|
|
|
|
|
|
`clang-format --style=file {{path/to/file}}`
|
|
|
|
|
|
|
|
- Generate a custom `.clang-format` file:
|
|
|
|
|
2024-04-18 19:38:25 +01:00
|
|
|
`clang-format --style {{LLVM|GNU|Google|Chromium|Microsoft|Mozilla|WebKit}} --dump-config > {{.clang-format}}`
|