HiveBrain v1.2.0
Get Started
← Back to all entries
snippetbashTip

clang-format — Auto-format C/C++/Java/JavaScript/Objective-C/Protobuf/C# code. More information: <https://clang.llv

Submitted by: @import:tldr-pages··
0
Viewed 0 times
autocommandformatjavascriptcliclang-formatjavaobjective

Problem

How to use the clang-format command: Auto-format C/C++/Java/JavaScript/Objective-C/Protobuf/C# code. More information: <https://clang.llvm.org/docs/ClangFormat.html>.

Solution

clang-format — Auto-format C/C++/Java/JavaScript/Objective-C/Protobuf/C# code. More information: <https://clang.llvm.org/docs/ClangFormat.html>.

Format a file and print the result to stdout:
clang-format {{path/to/file}}


Format a file in-place:
clang-format -i {{path/to/file}}


Format a file using a predefined coding style:
clang-format --style {{LLVM|GNU|Google|Chromium|Microsoft|Mozilla|WebKit}} {{path/to/file}}


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:
clang-format --style {{LLVM|GNU|Google|Chromium|Microsoft|Mozilla|WebKit}} --dump-config > {{.clang-format}}

Code Snippets

Format a file and print the result to `stdout`

clang-format {{path/to/file}}

Format a file in-place

clang-format -i {{path/to/file}}

Format a file using a predefined coding style

clang-format --style {{LLVM|GNU|Google|Chromium|Microsoft|Mozilla|WebKit}} {{path/to/file}}

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

clang-format --style {{LLVM|GNU|Google|Chromium|Microsoft|Mozilla|WebKit}} --dump-config > {{.clang-format}}

Context

tldr-pages: common/clang-format

Revisions (0)

No revisions yet.