CLANG-FORMAT(1)
π CLANG-FORMAT(1) β the clang-format girlies' manual
okay bestie so this is the manual page for clang-format (that's the β¨ User Commands β¨ section of the manual, section 1, in case you were wondering), and honestly? this little tool is about to change your whole life. sit down, hydrate, let's go. π«Ά
π NAME
clang-format β manual page for clang-format 21
π DESCRIPTION
OVERVIEW: it's a tool to format C/C++/Java/JavaScript/JSON/Objective-C/Protobuf/C# code. that's a lot of languages bestie and it handles all of them. no cap. π
so here's how the vibes work:
- if you pass no arguments at all, it formats the code coming in from standard input and writes the result out to standard output. classic glow-up pipeline. π
- if you give it
<file>s, it reformats those files. - if you give it
-itogether with<file>s, the files get edited in-place (aka it just rewrites them, for real, no take-backs). - otherwise (any other situation), the result is just written to standard output. soft launch. β¨
USAGE:
clang-format [options] [@<file>] [<file> ...]
β¨ OPTIONS β¨
Clang-format options:
--Werrorβ if you set this, formatting warnings get turned into errors. no more ignoring things, periodt. π€--Wno-error=<value>β if you set this, it does not error out on the specified warning type.=unknownβ if you set this, unknown format options are only warned about. this is the move when you wanna enable formatting even if your config has unknown (newer) options in it. π§
β οΈ use with caution bestie, because this might lead to dramatically differing format depending on whether an option is supported or not. it's giving chaos gremlin energy and not the cute kind. π
--assume-filename=<string>β sets the filename used to figure out the language and to find the.clang-formatfile. it's only used when reading from stdin. if you don't pass this, the.clang-formatfile is searched relative to the current working directory when reading stdin. unrecognized filenames are treated as C++. here's what's supported: πΈ- CSharp:
.cs - Java:
.java - JavaScript:
.js.mjs.cjs.ts - Json:
.json.ipynb - Objective-C:
.m.mm - Proto:
.proto.protodevel - TableGen:
.td - TextProto:
.txtpb.textpb.pb.txt.textproto.asciipb - Verilog:
.sv.svh.v.vh
- CSharp:
--cursor=<uint>β the position of the cursor when you're invokingclang-formatfrom an editor integration. editor girlies, this one's for you. π--dry-runβ if you set this, it does not actually make the formatting changes. just vibes, no consequences. π--dump-configβ dumps the configuration options to stdout and then exits. can be used with the-styleoption. iykyk. π--fail-on-incomplete-formatβ if you set this, it fails with exit code1on an incomplete format. dramatic? yes. useful? also yes. π₯--fallback-style=<string>β the name of the predefined style used as a fallback in caseclang-formatis invoked with-style=filebut can not find the.clang-formatfile to use. defaults to'LLVM'. use-fallback-style=noneto skip formatting entirely. π¦--ferror-limit=<uint>β sets the maximum number ofclang-formaterrors to emit before stopping (0= no limit). only used with--dry-runor-n. β--files=<filename>β a file containing a list of files to process, one per line. batch girlies rise. π-iβ inplace edit<file>s, if specified. this one writes over your actual files, so like... maybe commit first 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. pick a lane β-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. for the data girlies. β¨--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. sort those includes bestie, they're a mess. π§Ή--style=<string>β set 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.--style="{BasedOnStyle: llvm, IndentWidth: 8}"π₯
- a preset:
--verboseβ if set, shows the list of processed files. nosy in the best way. π
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.
π a lil sign-off
that's the whole page bestie, go forth and format. this was clang-format 21, from September 2026 β the CLANG-FORMAT(1) page, if you're keeping track. now go make your codebase pretty. slay, you got this. πβ¨π¦
π¦ where this page comes from
- ubuntu stonking: clang-format-21 1:21.1.8-10ubuntu2 Β· APACHE-2-LLVM-EXCEPTIONS
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms