1==========================
2Clang-Format Style Options
3==========================
4
5:doc:`ClangFormatStyleOptions` describes configurable formatting style options
6supported by :doc:`LibFormat` and :doc:`ClangFormat`.
7
8When using :program:`clang-format` command line utility or
9``clang::format::reformat(...)`` functions from code, one can either use one of
10the predefined styles (LLVM, Google, Chromium, Mozilla, WebKit) or create a
11custom style by configuring specific style options.
12
13
14Configuring Style with clang-format
15===================================
16
17:program:`clang-format` supports two ways to provide custom style options:
18directly specify style configuration in the ``-style=`` command line option or
19use ``-style=file`` and put style configuration in the ``.clang-format`` or
20``_clang-format`` file in the project directory.
21
22When using ``-style=file``, :program:`clang-format` for each input file will
23try to find the ``.clang-format`` file located in the closest parent directory
24of the input file. When the standard input is used, the search is started from
25the current directory.
26
27The ``.clang-format`` file uses YAML format:
28
29.. code-block:: yaml
30
31  key1: value1
32  key2: value2
33  # A comment.
34  ...
35
36The configuration file can consist of several sections each having different
37``Language:`` parameter denoting the programming language this section of the
38configuration is targeted at. See the description of the **Language** option
39below for the list of supported languages. The first section may have no
40language set, it will set the default style options for all lanugages.
41Configuration sections for specific language will override options set in the
42default section.
43
44When :program:`clang-format` formats a file, it auto-detects the language using
45the file name. When formatting standard input or a file that doesn't have the
46extension corresponding to its language, ``-assume-filename=`` option can be
47used to override the file name :program:`clang-format` uses to detect the
48language.
49
50An example of a configuration file for multiple languages:
51
52.. code-block:: yaml
53
54  ---
55  # We'll use defaults from the LLVM style, but with 4 columns indentation.
56  BasedOnStyle: LLVM
57  IndentWidth: 4
58  ---
59  Language: Cpp
60  # Force pointers to the type for C++.
61  DerivePointerAlignment: false
62  PointerAlignment: Left
63  ---
64  Language: JavaScript
65  # Use 100 columns for JS.
66  ColumnLimit: 100
67  ---
68  Language: Proto
69  # Don't format .proto files.
70  DisableFormat: true
71  ...
72
73An easy way to get a valid ``.clang-format`` file containing all configuration
74options of a certain predefined style is:
75
76.. code-block:: console
77
78  clang-format -style=llvm -dump-config > .clang-format
79
80When specifying configuration in the ``-style=`` option, the same configuration
81is applied for all input files. The format of the configuration is:
82
83.. code-block:: console
84
85  -style='{key1: value1, key2: value2, ...}'
86
87
88Disabling Formatting on a Piece of Code
89=======================================
90
91Clang-format understands also special comments that switch formatting in a
92delimited range. The code between a comment ``// clang-format off`` or
93``/* clang-format off */`` up to a comment ``// clang-format on`` or
94``/* clang-format on */`` will not be formatted. The comments themselves
95will be formatted (aligned) normally.
96
97.. code-block:: c++
98
99  int formatted_code;
100  // clang-format off
101      void    unformatted_code  ;
102  // clang-format on
103  void formatted_code_again;
104
105
106Configuring Style in Code
107=========================
108
109When using ``clang::format::reformat(...)`` functions, the format is specified
110by supplying the `clang::format::FormatStyle
111<http://clang.llvm.org/doxygen/structclang_1_1format_1_1FormatStyle.html>`_
112structure.
113
114
115Configurable Format Style Options
116=================================
117
118This section lists the supported style options. Value type is specified for
119each option. For enumeration types possible values are specified both as a C++
120enumeration member (with a prefix, e.g. ``LS_Auto``), and as a value usable in
121the configuration (without a prefix: ``Auto``).
122
123
124**BasedOnStyle** (``string``)
125  The style used for all options not specifically set in the configuration.
126
127  This option is supported only in the :program:`clang-format` configuration
128  (both within ``-style='{...}'`` and the ``.clang-format`` file).
129
130  Possible values:
131
132  * ``LLVM``
133    A style complying with the `LLVM coding standards
134    <http://llvm.org/docs/CodingStandards.html>`_
135  * ``Google``
136    A style complying with `Google's C++ style guide
137    <http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml>`_
138  * ``Chromium``
139    A style complying with `Chromium's style guide
140    <http://www.chromium.org/developers/coding-style>`_
141  * ``Mozilla``
142    A style complying with `Mozilla's style guide
143    <https://developer.mozilla.org/en-US/docs/Developer_Guide/Coding_Style>`_
144  * ``WebKit``
145    A style complying with `WebKit's style guide
146    <http://www.webkit.org/coding/coding-style.html>`_
147
148.. START_FORMAT_STYLE_OPTIONS
149
150**AccessModifierOffset** (``int``)
151  The extra indent or outdent of access modifiers, e.g. ``public:``.
152
153**AlignAfterOpenBracket** (``BracketAlignmentStyle``)
154  If ``true``, horizontally aligns arguments after an open bracket.
155
156  This applies to round brackets (parentheses), angle brackets and square
157  brackets. This will result in formattings like
158
159  Possible values:
160
161  * ``BAS_Align`` (in configuration: ``Align``)
162    Align parameters on the open bracket, e.g.:
163
164    .. code-block:: c++
165
166      someLongFunction(argument1,
167                       argument2);
168  * ``BAS_DontAlign`` (in configuration: ``DontAlign``)
169    Don't align, instead use ``ContinuationIndentWidth``, e.g.:
170
171    .. code-block:: c++
172
173      someLongFunction(argument1,
174          argument2);
175  * ``BAS_AlwaysBreak`` (in configuration: ``AlwaysBreak``)
176    Always break after an open bracket, if the parameters don't fit
177    on a single line, e.g.:
178
179    .. code-block:: c++
180
181      someLongFunction(
182          argument1, argument2);
183
184
185**AlignConsecutiveAssignments** (``bool``)
186  If ``true``, aligns consecutive assignments.
187
188  This will align the assignment operators of consecutive lines. This
189  will result in formattings like
190
191  .. code-block:: c++
192
193    int aaaa = 12;
194    int b    = 23;
195    int ccc  = 23;
196
197**AlignConsecutiveDeclarations** (``bool``)
198  If ``true``, aligns consecutive declarations.
199
200  This will align the declaration names of consecutive lines. This
201  will result in formattings like
202
203  .. code-block:: c++
204
205    int         aaaa = 12;
206    float       b = 23;
207    std::string ccc = 23;
208
209**AlignEscapedNewlinesLeft** (``bool``)
210  If ``true``, aligns escaped newlines as far left as possible.
211  Otherwise puts them into the right-most column.
212
213**AlignOperands** (``bool``)
214  If ``true``, horizontally align operands of binary and ternary
215  expressions.
216
217**AlignTrailingComments** (``bool``)
218  If ``true``, aligns trailing comments.
219
220**AllowAllParametersOfDeclarationOnNextLine** (``bool``)
221  Allow putting all parameters of a function declaration onto
222  the next line even if ``BinPackParameters`` is ``false``.
223
224**AllowShortBlocksOnASingleLine** (``bool``)
225  Allows contracting simple braced statements to a single line.
226
227  E.g., this allows ``if (a) { return; }`` to be put on a single line.
228
229**AllowShortCaseLabelsOnASingleLine** (``bool``)
230  If ``true``, short case labels will be contracted to a single line.
231
232**AllowShortFunctionsOnASingleLine** (``ShortFunctionStyle``)
233  Dependent on the value, ``int f() { return 0; }`` can be put
234  on a single line.
235
236  Possible values:
237
238  * ``SFS_None`` (in configuration: ``None``)
239    Never merge functions into a single line.
240  * ``SFS_Empty`` (in configuration: ``Empty``)
241    Only merge empty functions.
242  * ``SFS_Inline`` (in configuration: ``Inline``)
243    Only merge functions defined inside a class. Implies "empty".
244  * ``SFS_All`` (in configuration: ``All``)
245    Merge all functions fitting on a single line.
246
247
248**AllowShortIfStatementsOnASingleLine** (``bool``)
249  If ``true``, ``if (a) return;`` can be put on a single
250  line.
251
252**AllowShortLoopsOnASingleLine** (``bool``)
253  If ``true``, ``while (true) continue;`` can be put on a
254  single line.
255
256**AlwaysBreakAfterDefinitionReturnType** (``DefinitionReturnTypeBreakingStyle``)
257  The function definition return type breaking style to use.
258
259  Possible values:
260
261  * ``DRTBS_None`` (in configuration: ``None``)
262    Break after return type automatically.
263    ``PenaltyReturnTypeOnItsOwnLine`` is taken into account.
264  * ``DRTBS_All`` (in configuration: ``All``)
265    Always break after the return type.
266  * ``DRTBS_TopLevel`` (in configuration: ``TopLevel``)
267    Always break after the return types of top level functions.
268
269
270**AlwaysBreakBeforeMultilineStrings** (``bool``)
271  If ``true``, always break before multiline string literals.
272
273  This flag is mean to make cases where there are multiple multiline strings
274  in a file look more consistent. Thus, it will only take effect if wrapping
275  the string at that point leads to it being indented
276  ``ContinuationIndentWidth`` spaces from the start of the line.
277
278**AlwaysBreakTemplateDeclarations** (``bool``)
279  If ``true``, always break after the ``template<...>`` of a
280  template declaration.
281
282**BinPackArguments** (``bool``)
283  If ``false``, a function call's arguments will either be all on the
284  same line or will have one line each.
285
286**BinPackParameters** (``bool``)
287  If ``false``, a function declaration's or function definition's
288  parameters will either all be on the same line or will have one line each.
289
290**BraceWrapping** (``BraceWrappingFlags``)
291  Control of individual brace wrapping cases.
292
293  If ``BreakBeforeBraces`` is set to ``custom``, use this to specify how each
294  individual brace case should be handled. Otherwise, this is ignored.
295
296  Nested configuration flags:
297
298  * ``bool AfterClass`` Wrap class definitions.
299  * ``bool AfterControlStatement`` Wrap control statements (if/for/while/switch/..).
300  * ``bool AfterEnum`` Wrap enum definitions.
301  * ``bool AfterFunction`` Wrap function definitions.
302  * ``bool AfterNamespace`` Wrap namespace definitions.
303  * ``bool AfterObjCDeclaration`` Wrap ObjC definitions (@autoreleasepool, interfaces, ..).
304  * ``bool AfterStruct`` Wrap struct definitions.
305  * ``bool AfterUnion`` Wrap union definitions.
306  * ``bool BeforeCatch`` Wrap before ``catch``.
307  * ``bool BeforeElse`` Wrap before ``else``.
308  * ``bool IndentBraces`` Indent the wrapped braces themselves.
309
310
311**BreakAfterJavaFieldAnnotations** (``bool``)
312  Break after each annotation on a field in Java files.
313
314**BreakBeforeBinaryOperators** (``BinaryOperatorStyle``)
315  The way to wrap binary operators.
316
317  Possible values:
318
319  * ``BOS_None`` (in configuration: ``None``)
320    Break after operators.
321  * ``BOS_NonAssignment`` (in configuration: ``NonAssignment``)
322    Break before operators that aren't assignments.
323  * ``BOS_All`` (in configuration: ``All``)
324    Break before operators.
325
326
327**BreakBeforeBraces** (``BraceBreakingStyle``)
328  The brace breaking style to use.
329
330  Possible values:
331
332  * ``BS_Attach`` (in configuration: ``Attach``)
333    Always attach braces to surrounding context.
334  * ``BS_Linux`` (in configuration: ``Linux``)
335    Like ``Attach``, but break before braces on function, namespace and
336    class definitions.
337  * ``BS_Mozilla`` (in configuration: ``Mozilla``)
338    Like ``Attach``, but break before braces on enum, function, and record
339    definitions.
340  * ``BS_Stroustrup`` (in configuration: ``Stroustrup``)
341    Like ``Attach``, but break before function definitions, 'catch', and 'else'.
342  * ``BS_Allman`` (in configuration: ``Allman``)
343    Always break before braces.
344  * ``BS_GNU`` (in configuration: ``GNU``)
345    Always break before braces and add an extra level of indentation to
346    braces of control statements, not to those of class, function
347    or other definitions.
348  * ``BS_WebKit`` (in configuration: ``WebKit``)
349    Like ``Attach``, but break before functions.
350  * ``BS_Custom`` (in configuration: ``Custom``)
351    Configure each individual brace in ``BraceWrapping``.
352
353
354**BreakBeforeTernaryOperators** (``bool``)
355  If ``true``, ternary operators will be placed after line breaks.
356
357**BreakConstructorInitializersBeforeComma** (``bool``)
358  Always break constructor initializers before commas and align
359  the commas with the colon.
360
361**ColumnLimit** (``unsigned``)
362  The column limit.
363
364  A column limit of ``0`` means that there is no column limit. In this case,
365  clang-format will respect the input's line breaking decisions within
366  statements unless they contradict other rules.
367
368**CommentPragmas** (``std::string``)
369  A regular expression that describes comments with special meaning,
370  which should not be split into lines or otherwise changed.
371
372**ConstructorInitializerAllOnOneLineOrOnePerLine** (``bool``)
373  If the constructor initializers don't fit on a line, put each
374  initializer on its own line.
375
376**ConstructorInitializerIndentWidth** (``unsigned``)
377  The number of characters to use for indentation of constructor
378  initializer lists.
379
380**ContinuationIndentWidth** (``unsigned``)
381  Indent width for line continuations.
382
383**Cpp11BracedListStyle** (``bool``)
384  If ``true``, format braced lists as best suited for C++11 braced
385  lists.
386
387  Important differences:
388  - No spaces inside the braced list.
389  - No line break before the closing brace.
390  - Indentation with the continuation indent, not with the block indent.
391
392  Fundamentally, C++11 braced lists are formatted exactly like function
393  calls would be formatted in their place. If the braced list follows a name
394  (e.g. a type or variable name), clang-format formats as if the ``{}`` were
395  the parentheses of a function call with that name. If there is no name,
396  a zero-length name is assumed.
397
398**DerivePointerAlignment** (``bool``)
399  If ``true``, analyze the formatted file for the most common
400  alignment of & and \*. ``PointerAlignment`` is then used only as fallback.
401
402**DisableFormat** (``bool``)
403  Disables formatting completely.
404
405**ExperimentalAutoDetectBinPacking** (``bool``)
406  If ``true``, clang-format detects whether function calls and
407  definitions are formatted with one parameter per line.
408
409  Each call can be bin-packed, one-per-line or inconclusive. If it is
410  inconclusive, e.g. completely on one line, but a decision needs to be
411  made, clang-format analyzes whether there are other bin-packed cases in
412  the input file and act accordingly.
413
414  NOTE: This is an experimental flag, that might go away or be renamed. Do
415  not use this in config files, etc. Use at your own risk.
416
417**ForEachMacros** (``std::vector<std::string>``)
418  A vector of macros that should be interpreted as foreach loops
419  instead of as function calls.
420
421  These are expected to be macros of the form:
422
423  .. code-block:: c++
424
425    FOREACH(<variable-declaration>, ...)
426      <loop-body>
427
428  In the .clang-format configuration file, this can be configured like:
429
430  .. code-block:: c++
431
432    ForEachMacros: ['RANGES_FOR', 'FOREACH']
433
434  For example: BOOST_FOREACH.
435
436**IncludeCategories** (``std::vector<IncludeCategory>``)
437  Regular expressions denoting the different #include categories used
438  for ordering #includes.
439
440  These regular expressions are matched against the filename of an include
441  (including the <> or "") in order. The value belonging to the first
442  matching regular expression is assigned and #includes are sorted first
443  according to increasing category number and then alphabetically within
444  each category.
445
446  If none of the regular expressions match, UINT_MAX is assigned as
447  category. The main header for a source file automatically gets category 0,
448  so that it is kept at the beginning of the #includes
449  (http://llvm.org/docs/CodingStandards.html#include-style).
450
451  To configure this in the .clang-format file, use:
452
453  .. code-block:: c++
454
455    IncludeCategories:
456      - Regex:           '^"(llvm|llvm-c|clang|clang-c)/'
457        Priority:        2
458      - Regex:           '^(<|"(gtest|isl|json)/)'
459        Priority:        3
460      - Regex:           '.\*'
461        Priority:        1
462
463**IndentCaseLabels** (``bool``)
464  Indent case labels one level from the switch statement.
465
466  When ``false``, use the same indentation level as for the switch statement.
467  Switch statement body is always indented one level more than case labels.
468
469**IndentWidth** (``unsigned``)
470  The number of columns to use for indentation.
471
472**IndentWrappedFunctionNames** (``bool``)
473  Indent if a function definition or declaration is wrapped after the
474  type.
475
476**KeepEmptyLinesAtTheStartOfBlocks** (``bool``)
477  If true, empty lines at the start of blocks are kept.
478
479**Language** (``LanguageKind``)
480  Language, this format style is targeted at.
481
482  Possible values:
483
484  * ``LK_None`` (in configuration: ``None``)
485    Do not use.
486  * ``LK_Cpp`` (in configuration: ``Cpp``)
487    Should be used for C, C++, ObjectiveC, ObjectiveC++.
488  * ``LK_Java`` (in configuration: ``Java``)
489    Should be used for Java.
490  * ``LK_JavaScript`` (in configuration: ``JavaScript``)
491    Should be used for JavaScript.
492  * ``LK_Proto`` (in configuration: ``Proto``)
493    Should be used for Protocol Buffers
494    (https://developers.google.com/protocol-buffers/).
495
496
497**MacroBlockBegin** (``std::string``)
498  A regular expression matching macros that start a block.
499
500**MacroBlockEnd** (``std::string``)
501  A regular expression matching macros that end a block.
502
503**MaxEmptyLinesToKeep** (``unsigned``)
504  The maximum number of consecutive empty lines to keep.
505
506**NamespaceIndentation** (``NamespaceIndentationKind``)
507  The indentation used for namespaces.
508
509  Possible values:
510
511  * ``NI_None`` (in configuration: ``None``)
512    Don't indent in namespaces.
513  * ``NI_Inner`` (in configuration: ``Inner``)
514    Indent only in inner namespaces (nested in other namespaces).
515  * ``NI_All`` (in configuration: ``All``)
516    Indent in all namespaces.
517
518
519**ObjCBlockIndentWidth** (``unsigned``)
520  The number of characters to use for indentation of ObjC blocks.
521
522**ObjCSpaceAfterProperty** (``bool``)
523  Add a space after ``@property`` in Objective-C, i.e. use
524  ``\@property (readonly)`` instead of ``\@property(readonly)``.
525
526**ObjCSpaceBeforeProtocolList** (``bool``)
527  Add a space in front of an Objective-C protocol list, i.e. use
528  ``Foo <Protocol>`` instead of ``Foo<Protocol>``.
529
530**PenaltyBreakBeforeFirstCallParameter** (``unsigned``)
531  The penalty for breaking a function call after "call(".
532
533**PenaltyBreakComment** (``unsigned``)
534  The penalty for each line break introduced inside a comment.
535
536**PenaltyBreakFirstLessLess** (``unsigned``)
537  The penalty for breaking before the first ``<<``.
538
539**PenaltyBreakString** (``unsigned``)
540  The penalty for each line break introduced inside a string literal.
541
542**PenaltyExcessCharacter** (``unsigned``)
543  The penalty for each character outside of the column limit.
544
545**PenaltyReturnTypeOnItsOwnLine** (``unsigned``)
546  Penalty for putting the return type of a function onto its own
547  line.
548
549**PointerAlignment** (``PointerAlignmentStyle``)
550  Pointer and reference alignment style.
551
552  Possible values:
553
554  * ``PAS_Left`` (in configuration: ``Left``)
555    Align pointer to the left.
556  * ``PAS_Right`` (in configuration: ``Right``)
557    Align pointer to the right.
558  * ``PAS_Middle`` (in configuration: ``Middle``)
559    Align pointer in the middle.
560
561
562**SpaceAfterCStyleCast** (``bool``)
563  If ``true``, a space may be inserted after C style casts.
564
565**SpaceBeforeAssignmentOperators** (``bool``)
566  If ``false``, spaces will be removed before assignment operators.
567
568**SpaceBeforeParens** (``SpaceBeforeParensOptions``)
569  Defines in which cases to put a space before opening parentheses.
570
571  Possible values:
572
573  * ``SBPO_Never`` (in configuration: ``Never``)
574    Never put a space before opening parentheses.
575  * ``SBPO_ControlStatements`` (in configuration: ``ControlStatements``)
576    Put a space before opening parentheses only after control statement
577    keywords (``for/if/while...``).
578  * ``SBPO_Always`` (in configuration: ``Always``)
579    Always put a space before opening parentheses, except when it's
580    prohibited by the syntax rules (in function-like macro definitions) or
581    when determined by other style rules (after unary operators, opening
582    parentheses, etc.)
583
584
585**SpaceInEmptyParentheses** (``bool``)
586  If ``true``, spaces may be inserted into '()'.
587
588**SpacesBeforeTrailingComments** (``unsigned``)
589  The number of spaces before trailing line comments
590  (``//`` - comments).
591
592  This does not affect trailing block comments (``/**/`` - comments) as those
593  commonly have different usage patterns and a number of special cases.
594
595**SpacesInAngles** (``bool``)
596  If ``true``, spaces will be inserted after '<' and before '>' in
597  template argument lists
598
599**SpacesInCStyleCastParentheses** (``bool``)
600  If ``true``, spaces may be inserted into C style casts.
601
602**SpacesInContainerLiterals** (``bool``)
603  If ``true``, spaces are inserted inside container literals (e.g.
604  ObjC and Javascript array and dict literals).
605
606**SpacesInParentheses** (``bool``)
607  If ``true``, spaces will be inserted after '(' and before ')'.
608
609**SpacesInSquareBrackets** (``bool``)
610  If ``true``, spaces will be inserted after '[' and before ']'.
611
612**Standard** (``LanguageStandard``)
613  Format compatible with this standard, e.g. use
614  ``A<A<int> >`` instead of ``A<A<int>>`` for LS_Cpp03.
615
616  Possible values:
617
618  * ``LS_Cpp03`` (in configuration: ``Cpp03``)
619    Use C++03-compatible syntax.
620  * ``LS_Cpp11`` (in configuration: ``Cpp11``)
621    Use features of C++11 (e.g. ``A<A<int>>`` instead of
622    ``A<A<int> >``).
623  * ``LS_Auto`` (in configuration: ``Auto``)
624    Automatic detection based on the input.
625
626
627**TabWidth** (``unsigned``)
628  The number of columns used for tab stops.
629
630**UseTab** (``UseTabStyle``)
631  The way to use tab characters in the resulting file.
632
633  Possible values:
634
635  * ``UT_Never`` (in configuration: ``Never``)
636    Never use tab.
637  * ``UT_ForIndentation`` (in configuration: ``ForIndentation``)
638    Use tabs only for indentation.
639  * ``UT_Always`` (in configuration: ``Always``)
640    Use tabs whenever we need to fill whitespace that spans at least from
641    one tab stop to the next one.
642
643
644.. END_FORMAT_STYLE_OPTIONS
645
646Adding additional style options
647===============================
648
649Each additional style option adds costs to the clang-format project. Some of
650these costs affect the clang-format developement itself, as we need to make
651sure that any given combination of options work and that new features don't
652break any of the existing options in any way. There are also costs for end users
653as options become less discoverable and people have to think about and make a
654decision on options they don't really care about.
655
656The goal of the clang-format project is more on the side of supporting a
657limited set of styles really well as opposed to supporting every single style
658used by a codebase somewhere in the wild. Of course, we do want to support all
659major projects and thus have established the following bar for adding style
660options. Each new style option must ..
661
662  * be used in a project of significant size (have dozens of contributors)
663  * have a publicly accessible style guide
664  * have a person willing to contribute and maintain patches
665
666Examples
667========
668
669A style similar to the `Linux Kernel style
670<https://www.kernel.org/doc/Documentation/CodingStyle>`_:
671
672.. code-block:: yaml
673
674  BasedOnStyle: LLVM
675  IndentWidth: 8
676  UseTab: Always
677  BreakBeforeBraces: Linux
678  AllowShortIfStatementsOnASingleLine: false
679  IndentCaseLabels: false
680
681The result is (imagine that tabs are used for indentation here):
682
683.. code-block:: c++
684
685  void test()
686  {
687          switch (x) {
688          case 0:
689          case 1:
690                  do_something();
691                  break;
692          case 2:
693                  do_something_else();
694                  break;
695          default:
696                  break;
697          }
698          if (condition)
699                  do_something_completely_different();
700
701          if (x == y) {
702                  q();
703          } else if (x > y) {
704                  w();
705          } else {
706                  r();
707          }
708  }
709
710A style similar to the default Visual Studio formatting style:
711
712.. code-block:: yaml
713
714  UseTab: Never
715  IndentWidth: 4
716  BreakBeforeBraces: Allman
717  AllowShortIfStatementsOnASingleLine: false
718  IndentCaseLabels: false
719  ColumnLimit: 0
720
721The result is:
722
723.. code-block:: c++
724
725  void test()
726  {
727      switch (suffix)
728      {
729      case 0:
730      case 1:
731          do_something();
732          break;
733      case 2:
734          do_something_else();
735          break;
736      default:
737          break;
738      }
739      if (condition)
740          do_somthing_completely_different();
741
742      if (x == y)
743      {
744          q();
745      }
746      else if (x > y)
747      {
748          w();
749      }
750      else
751      {
752          r();
753      }
754  }
755
756