CLANG-FORMAT(1)

πŸ“¦
version 22.1.8 Β· 3 versions
, in ubuntu stonking

🌸 CLANG-FORMAT 🌸

bestie. come here. sit down. you're about to meet clang-format 22 and honestly? your codebase is gonna thank you. this is the manual page, but make it cute and make it make sense.


πŸ’– NAME πŸ’–

clang-format β€” ok so this is literally the manual page for clang-format 22. that's it. that's the name. iconic.


✨ DESCRIPTION ✨

OVERVIEW: it's a whole tool that formats your C/C++/Java/JavaScript/JSON/Objective-C/Protobuf/C# code. like, it takes your chaotic little lines and makes them look like someone with taste touched them. πŸ’…

okay here's the tea on how it actually behaves:

  • give it no arguments at all? it reads the code from standard input and writes the formatted result to standard output. a little glow-up pipeline, no notes.
  • give it some <file>s? it reformats the files.
  • give it -i together with <file>s? bestie, the files get edited in-place. like, actually changed. on disk. for real. 🫢
  • none of the above? the result goes to standard output. simple.

USAGE:

clang-format [options] [@<file>] [<file> ...]

πŸŽ€ OPTIONS πŸŽ€

πŸ’œ Clang-format options πŸ’œ

  • --Werror β€” if you set this, formatting warnings get promoted to actual errors. no more soft-launching problems. πŸ’€
  • --Wno-error=<value> β€” if you set this, it won't error out on the warning type you specify. pick your battles, queen.
    • =unknown β€” if set, unknown format options are only warned about.
      • this is the one you use when you wanna enable formatting even though your configuration contains unknown (newer) options. ⚠️ but use with caution, because this might lead to dramatically differing format depending on whether an option is supported or not. so dramatic. be careful bestie.
  • --assume-filename=<string> β€” sets the filename used to determine the language and to find the .clang-format file. only used when reading from stdin. if you don't pass it, the .clang-format file is searched relative to the current working directory when reading stdin. unrecognized filenames get treated as C++. 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
  • --cursor=<uint> β€” the position of the cursor when you're invoking clang-format from an editor integration. hi editor besties πŸ‘‹
  • --dry-run β€” if set, it does not actually make the formatting changes. it's the window-shopping of formatting. πŸ›οΈ
  • --dump-config β€” dumps configuration options to stdout and exits. can be used with the -style option.
  • --fail-on-incomplete-format β€” if set, it fails with exit code 1 on an incomplete format. harsh but honest.
  • --fallback-style=<string> β€” the name of the predefined style used as a fallback when clang-format is invoked with -style=file but can not find the .clang-format file to use. defaults to 'LLVM'. pass -fallback-style=none to skip formatting entirely. πŸ™ˆ
  • --ferror-limit=<uint> β€” sets the maximum number of clang-format errors to emit before stopping (0 = no limit). only used with --dry-run or -n.
  • --files=<filename> β€” a file containing a list of files to process, one per line. a whole roster. πŸ“‹
  • -i β€” inplace edit the <file>s, if specified. this one writes, fr fr.
  • --length=<uint> β€” format a range of this length (in bytes). multiple ranges can be formatted by specifying several -offset and -length pairs. when only a single -offset is specified without -length, clang-format will 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 -lines arguments. can't be used with -offset and -length. can only be used with one input file.
  • -n β€” an alias for --dry-run. same vibe, shorter name. ✨
  • --offset=<uint> β€” format a range starting at this byte offset. multiple ranges can be formatted by specifying several -offset and -length pairs. can only be used with one input file.
  • --output-replacements-xml β€” outputs replacements as XML.
  • --qualifier-alignment=<string> β€” if set, overrides the qualifier alignment style determined by the QualifierAlignment style flag.
  • --sort-includes β€” if set, overrides the include sorting behavior determined by the SortIncludes style flag.
  • --style=<string> β€” sets the coding style. <string> can be:
    1. A preset: LLVM, GNU, Google, Chromium, Microsoft, Mozilla, WebKit.
    2. 'file' to load style configuration from a .clang-format file in one of the parent directories of the source file (for stdin, see --assume-filename). if no .clang-format file is found, it falls back to --fallback-style. --style=file is the default.
    3. 'file:<format_file_path>' to explicitly specify the configuration file.
    4. "{key: value, ...}" to set specific parameters, e.g.:
--style="{BasedOnStyle: llvm, IndentWidth: 8}"
  • --verbose β€” if set, it shows the list of processed files. nosy (affectionate).

🌈 Generic Options 🌈

  • --help β€” display available options (--help-hidden for more).
  • --help-list β€” display list of available options (--help-list-hidden for more).
  • --version β€” display the version of this program.

and that's the whole thing, bestie. go forth and format. your indentation is gonna be so slay. πŸ’…βœ¨

this was the clang-format 22 manual page, dated September 2026 β€” mwah, take care of her, and take care of your code. πŸŽ€πŸ¦‹πŸŒŸ

πŸ“¦ where this page comes from