CLANG-FORMAT(1)
π clang-format β the manual page, bestie edition π
okay so this is the manual page for clang-format, from section 1 (User Commands). yes, that clang-format. the one your editor keeps yelling at you to configure. let's get into it β¨
πΈ DESCRIPTION πΈ
OVERVIEW: it's a tool that formats C/C++/Java/JavaScript/Objective-C/Protobuf/C# code. that's the whole gig. it takes your chaotic little code gremlin and makes it presentable. π
so here's how it behaves, and this part matters:
- no arguments at all? it reads code from standard input and writes the result to standard output.
- you pass
<file>s? it reformats those files. - you pass
-itogether with<file>s? it edits the files in-place. no takebacks. - otherwise? the result goes to standard output.
USAGE:
clang-format [options] [<file> ...]
β¨ OPTIONS β¨
π Clang-format options
--Werrorβ if you set this, formatting warnings get promoted to full-on errors. no more gentle vibes, we're being serious now.--Wno-error=<value>β if you set this, it won't error out on the warning type you named.=unknownβ if you set this one, unknown format options are only warned about instead of being a whole thing.
this is what you use to keep formatting going even when your config has unknown (newer) options in it. use with caution tho β because depending on whether an option is supported or not, your format could come out dramatically different. π
--assume-filename=<string>β overrides the filename that gets used to figure out the language. when it's reading from stdin, clang-format assumes this filename to determine the language. iykyk.--cursor=<uint>β the position of the cursor when you invoke clang-format from an editor integration. (hi, editor plugins π)--dry-runβ if set, it does not actually make the formatting changes. all vibes, no edits.--dump-configβ dumps the configuration options to stdout and then exits. can be used together with the-styleoption.--fallback-style=<string>β the name of the predefined style used as a fallback when clang-format is invoked with-style=filebut can't find the.clang-formatfile to use. use-fallback-style=noneto skip formatting entirely.--ferror-limit=<uint>β sets the max number of clang-format errors to emit before stopping (0= no limit). only used with--dry-runor-n.-iβ inplace-edit the<file>s, if specified. βοΈ--length=<uint>β format a range of this length (in bytes). you can format multiple ranges by specifying several-offsetand-lengthpairs. when only a single-offsetis given without-length, clang-format formats 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, bestie, don't forget). multiple ranges = 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 again = several-offsetand-lengthpairs. can only be used with one input file.--output-replacements-xmlβ outputs the replacements as XML.--sort-includesβ if set, this overrides the include sorting behavior that theSortIncludesstyle flag would have decided. it's giving main character energy, honestly.--style=<string>β the coding style. currently supported:LLVM,GNU,Google,Chromium,Microsoft,Mozilla,WebKit.
use -style=file to load the style config from a .clang-format file sitting in one of the parent directories of the source file (or the current directory, if you're on stdin). use -style="{key: value, ...}" to set specific parameters, like:
-style="{BasedOnStyle: llvm, IndentWidth: 8}"
--verboseβ if set, it shows you the list of processed files. so you can see exactly what it touched. π
π Generic Options
--helpβ display the available options (there's--help-hiddenfor more, if you're nosy).--help-listβ display the list of available options (and--help-list-hiddenfor more).--versionβ display the version of this program.
and that's the whole page, bestie. every flag, every default, every warning, preserved exactly β just with way better vibes. go forth and format. π¦
this was clang-format version 12, from February 2022, section 1 of the manual. slay. periodt. π
π¦ where this page comes from
- ubuntu jammy: clang-format-12 1:12.0.1-19ubuntu3 Β· APACHE-2-LLVM-EXCEPTIONS
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms