Files
tldr/pages.zh/common/clang-format.md

24 lines
739 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# clang-format
> 自动格式化 C/C++/Java/JavaScript/Objective-C/Protobuf/C# 代码。
> 更多信息:<https://clang.llvm.org/docs/ClangFormat.html>。
- 格式化文件并将结果打印到 `stdout`
`clang-format {{path/to/file}}`
- 就地格式化文件:
`clang-format -i {{path/to/file}}`
- 使用预定义编码风格格式化文件:
`clang-format --style {{LLVM|GNU|Google|Chromium|Microsoft|Mozilla|WebKit}} {{path/to/file}}`
- 使用源文件的某个父目录中的 `.clang-format` 文件格式化文件:
`clang-format --style=file {{path/to/file}}`
- 生成自定义的 `.clang-format` 文件:
`clang-format --style {{LLVM|GNU|Google|Chromium|Microsoft|Mozilla|WebKit}} --dump-config > {{.clang-format}}`