CLANG-FORMAT(1)
π NAME π
clang-format β bestie, it's the manual page for clang-format 13, a User Command, and it is the moment your code gets its life together β¨
π¦ DESCRIPTION π¦
OVERVIEW: it's a whole tool to format C/C++/Java/JavaScript/JSON/Objective-C/Protobuf/C# code. that's nine languages. she does not play π
okay so here's the tea on how it behaves:
- no arguments at all? she reads your code from standard input and writes the glow-up to standard output π
- you hand her some
<file>s? she reformats those files. - you give her
-itogether with<file>s? she edits them in-place, no takebacks, no cap π«Ά - anything else? the result goes to standard output.
USAGE: clang-format [options] [<file> ...]
OPTIONS:
β¨ Clang-format options β¨
--Werrorβ if set, it turns formatting warnings into errors π€--Wno-error=<value>β if set, don't error out on the specified warning type. the value=unknownmeans: if set, unknown format options are only warned about.- the whole point of that one: it lets you actually enable formatting even when your config contains unknown (newer) options.
use with caution β οΈ because this might lead to dramatically differing format depending on an option being supported or not. yes she said dramatically. she meant it.
--assume-filename=<string>β override the filename used to determine the language. when she's reading from stdin,clang-formatassumes this filename to figure out the language π§--cursor=<uint>β the position of the cursor when you're invokingclang-formatfrom an editor integration π--dry-runβ if set, she does not actually make the formatting changes. window shopping only π--dump-configβ dump configuration options to stdout and exit. can be used with the-styleoption. it's giving receipts π§Ύ--fallback-style=<string>β the name of the predefined style used as a fallback in caseclang-formatis invoked with-style=file, but can not find the.clang-formatfile to use. 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.-iβ inplace edit<file>s, if specified. she's committing, bestie π--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 energy, 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 π--sort-includesβ if set, overrides the include sorting behavior determined by theSortIncludesstyle flag π--style=<string>β coding style, currently supports:LLVMGNUGoogleChromiumMicrosoftMozillaWebKit
use -style=file to load style configuration from a .clang-format file located in one of the parent directories of the source file (or current directory for stdin). use -style="{key: value, ...}" to set specific parameters, e.g.:
-style="{BasedOnStyle: llvm, IndentWidth: 8}"
that one right there? iconic. she ate π₯
--verboseβ if set, shows the list of processed files π
π 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
k bye bestie, go format something gorgeous πβ¨ππ¦πΈπ π«Ά
this was clang-format 13, from July 2023, running around as a User Command. mwah, see you in the group chat ππ
π¦ where this page comes from
- ubuntu jammy: clang-format-13 1:13.0.1-2ubuntu2.2 Β· APACHE-2-LLVM-EXCEPTIONS
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms