CLANG-FORMAT(1)

πŸ“¦
version 14.0.6 Β· 5 versions
, in ubuntu questing

πŸ’– CLANG-FORMAT πŸ’–

okay bestie, pull up a chair, because this is the manual page for clang-format, and yes it's a User Commands girly in section 1 of the manual. she's giving ✨tool✨ energy and honestly? obsessed.


🌸 NAME 🌸

clang-format β€” literally the manual page for clang-format 14, no cap πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

OVERVIEW: a tool to format C/C++/Java/JavaScript/JSON/Objective-C/Protobuf/C# code. she does it ALL, she contains multitudes, main character energy fr fr 🌈

so here's the vibe check on how she behaves:

  • if you give her no arguments at all, she formats the code coming in from standard input and writes the result straight to standard output πŸŽ€
  • if you hand her <file>s, she reformats the files 🫢
  • if -i shows up together with <file>s, the files get edited in-place (yes bestie, she's touching your actual files, be normal about it) 😭
  • otherwise, the result is written to the standard output πŸ’–

USAGE:

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

✨ OPTIONS ✨

πŸ’œ Clang-format options:

  • --Werror β€” if set, changes formatting warnings into errors. she said no more playing games, warnings are crimes now πŸ’€
  • --Wno-error=<value> β€” if set, don't error out on the specified warning type.
    • =unknown β€” if set, unknown format options are only warned about.

this can be used to enable formatting even if the configuration contains unknown (newer) options. > use with caution, as this might lead to dramatically differing format depending on an option being supported or not. like, dramatic dramatic. she's not kidding 🚨

  • --assume-filename=<string> β€” override the filename used to determine the language. when reading from stdin, clang-format assumes this filename to determine the language. it's giving "pretend i'm this file bestie" 🧚
  • --cursor=<uint> β€” the position of the cursor when invoking clang-format from an editor integration. editor besties, this one's for you πŸŽ€
  • --dry-run β€” if set, do not actually make the formatting changes. window shopping only, no purchasing πŸ’…
  • --dump-config β€” dump configuration options to stdout and exit. can be used with the -style option. it's giving "show me everything you got" πŸ‘‘
  • --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. use -fallback-style=none to skip formatting. the backup plan, the understudy, the safety net πŸ¦‹
  • --ferror-limit=<uint> β€” set the maximum number of clang-format errors to emit before stopping (0 = no limit). used only with --dry-run or -n. lowkey a "okay that's ENOUGH" setting 😭
  • --files=<string> β€” provide a list of files to run clang-format on. a whole squad, a whole roster 🫢
  • -i β€” inplace edit <file>s, if specified. she's going in and she's changing things, no going back πŸ™ˆ
  • --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. one file at a time, she's not doing group projects on this one πŸ’…
  • --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. it's the line-range girlie of the family ✨
  • -n β€” alias for --dry-run. same vibe, shorter name, iconic πŸ’–
  • --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. yes, XML. in this economy. πŸ”₯
  • --qualifier-alignment=<string> β€” if set, overrides the qualifier alignment style determined by the QualifierAlignment style flag. she said "i'm overriding that" periodt πŸ’…
  • --sort-includes β€” if set, overrides the include sorting behavior determined by the SortIncludes style flag. your includes, sorted, your way 🌸
  • --style=<string> β€” coding style, currently supports: LLVM, GNU, Google, Chromium, Microsoft, Mozilla, WebKit.

use -style=file to load style configuration from .clang-format file located in one of the parent directories of the source file (or current directory for stdin). use -style=file:<format_file_path> to explicitly specify the configuration file. use -style="{key: value, ...}" to set specific parameters, e.g.:

-style="{BasedOnStyle: llvm, IndentWidth: 8}"

(yes, that's verbatim, that's the exact syntax, don't @ me πŸ’–)

  • --verbose β€” if set, shows the list of processed files. she's narrating her own journey, and honestly? deserved πŸ‘‘

🌈 Generic Options:

  • --help β€” display available options (--help-hidden for more). the classic, the icon, the blueprint πŸŽ€
  • --help-list β€” display list of available options (--help-list-hidden for more). same energy, list format πŸ’…
  • --version β€” display the version of this program. she'll tell you who she is πŸ¦‹

bestie reminder: -i means in-place edits on real files. --dry-run / -n is your safe little preview. choose wisely, we love you πŸ’œ

and that's the whole page! this manual page came to you from clang-format 14, dated May 2025 β€” she's been around, she's been formatting, she's thriving. go forth and format, bestie, you've got this πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈπŸ’…πŸ«Ά

πŸ“¦ where this page comes from