CLANG-FORMAT(1)
π NAME π
clang-format β the manual page for clang-format 16. Yes bestie, that's the whole name section, she's short and she knows it. π
β¨ DESCRIPTION β¨
π OVERVIEW
Okay so, clang-format is a tool to format C/C++/Java/JavaScript/JSON/Objective-C/Protobuf/C# code. That's it. That's the gig. Multilingual queen behavior, no cap. π
Now here's how she actually acts, and this part is important so don't skim it:
- If you give her no arguments at all, she formats the code from standard input and writes the result to standard output. Zero drama. π«Ά
- If
<file>s are given, she reformats the files. - If
-iis specified together with<file>s, the files get edited in-place. (Careful, bestie β in-place means the original is gone-gone. π) - Otherwise, the result is written to the standard output.
π USAGE
clang-format [options] [<file> ...]
π οΈ OPTIONS
π₯ Clang-format options
--Werrorβ if you set this, formatting warnings get promoted to full-on errors. Glow-up, but make it hostile. π--Wno-error=<value>β if you set this, she won't error out on the specified warning type.=unknownβ if you set this, unknown format options are only warned about. You can use it to enable formatting even when the configuration contains unknown (newer) options. > Use with caution, because this might lead to dramatically differing format depending on whether an option is supported or not. Yeah. She said what she said. β οΈ
--assume-filename=<string>β sets the filename used to determine the language and to find the.clang-formatfile. Only used when reading from stdin. If this is not passed, the.clang-formatfile is searched relative to the current working directory when reading stdin. Unrecognized filenames are treated asC++. Here's what's supported, bestie, memorize it or don't:CSharp:.csJava:.javaJavaScript:.mjs.js.tsJson:.jsonObjective-C:.m.mmProto:.proto.protodevelTableGen:.tdTextProto:.textpb.pb.txt.textproto.asciipbVerilog:.sv.svh.v.vh
--cursor=<uint>β the position of the cursor when invokingclang-formatfrom an editor integration. Yes, this is how your editor knows where you were pointing. π±οΈ--dry-runβ if set, do not actually make the formatting changes. Just vibes. Just a peek. π--dump-configβ dump configuration options to stdout and exit. Can be used with the-styleoption.--fallback-style=<string>β the name of the predefined style used as a fallback in caseclang-formatis invoked with-style=file, but can't find the.clang-formatfile to use. Defaults to'LLVM'. Use-fallback-style=noneto skip formatting entirely. β--ferror-limit=<uint>β set the maximum number ofclang-formaterrors to emit before stopping (0= no limit). Used only with--dry-runor-n. π--files=<filename>β a file containing a list of files to process, one per line.-iβ inplace edit<file>s, if specified. π--length=<uint>β format a range of this length (in bytes). Multiple ranges can be formatted by specifying several-offsetand-lengthpairs. When only a single-offsetis specified without-length,clang-formatwill format up to the end of the file. Can only be used with one input file.--lines=<string>β<start line>:<end line>β format a range of lines (both 1-based). Multiple ranges can be formatted by specifying several-linesarguments. Can't be used with-offsetand-length. Can only be used with one input file.-nβ alias for--dry-run. Same girl, shorter name. β¨--offset=<uint>β format a range starting at this byte offset. Multiple ranges can be formatted by specifying several-offsetand-lengthpairs. Can only be used with one input file.--output-replacements-xmlβ output replacements as XML.--qualifier-alignment=<string>β if set, overrides the qualifier alignment style determined by theQualifierAlignmentstyle flag.--sort-includesβ if set, overrides the include sorting behavior determined by theSortIncludesstyle flag.--style=<string>β set the coding style.<string>can be:- A preset:
LLVM,GNU,Google,Chromium,Microsoft,Mozilla,WebKit. 'file'to load style configuration from a.clang-formatfile in one of the parent directories of the source file (for stdin, see--assume-filename). If no.clang-formatfile is found, it falls back to--fallback-style.--style=fileis the default. π'file:<format_file_path>'to explicitly specify the configuration file."{key: value, ...}"to set specific parameters, e.g.:
- A preset:
--style="{BasedOnStyle: llvm, IndentWidth: 8}"
--verboseβ if set, shows the list of processed files. Not me being nosy, it's literally the feature. π
β Generic Options
--helpβ display available options (--help-hiddenfor more).--help-listβ display list of available options (--help-list-hiddenfor more).--versionβ display the version of this program.
And that's the whole page, bestie!! You ate. Periodt. π¦πΈ
This lil masterpiece came to you from clang-format 16, dated October 2023. Go format something gorgeous, you main character. ππ
π¦ where this page comes from
- debian bookworm: clang-format-16 1:16.0.6-15~deb12u1 Β· APACHE-2-LLVM-EXCEPTIONS
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms