CLANG-FORMAT(1)

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

πŸ’… 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 -i together 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-format file. it's only used when reading from stdin. if you don't pass this, the .clang-format file 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
  • --cursor=<uint> β€” the position of the cursor when you're invoking clang-format from 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 -style option. iykyk. πŸ‘‘
  • --fail-on-incomplete-format β€” if you set this, it fails with exit code 1 on an incomplete format. dramatic? yes. useful? also yes. πŸ”₯
  • --fallback-style=<string> β€” the name of the predefined style used as a fallback in case clang-format is invoked with -style=file but can not find the .clang-format file to use. defaults to 'LLVM'. use -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. 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 -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. 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 -offset and -length pairs. 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 the QualifierAlignment style flag. πŸ’–
  • --sort-includes β€” if set, overrides the include sorting behavior determined by the SortIncludes style flag. sort those includes bestie, they're a mess. 🧹
  • --style=<string> β€” set 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, shows the list of processed files. nosy in the best way. πŸ‘€

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.

πŸŽ€ 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