Lines Matching +refs:clang +refs:format +refs:fallback +refs:style

13 :program:`clang-format` is located in `clang/tools/clang-format` and can be used
14 to format C/C++/Java/JavaScript/JSON/Objective-C/Protobuf/C# code.
20 $ clang-format --help
21 OVERVIEW: A tool to format C/C++/Java/JavaScript/JSON/Objective-C/Protobuf/C# code.
29 USAGE: clang-format [options] [@<file>] [<file> ...]
33 Clang-format options:
37 =unknown - If set, unknown format options are only warned about.
41 differing format depending on an option being
44 .clang-format file.
46 If this is not passed, the .clang-format file is searched
60 clang-format from an editor integration
63 Can be used with -style option.
64 --fallback-style=<string> - The name of the predefined style used as a
65 fallback in case clang-format is invoked with
66 -style=file, but can not find the .clang-format
68 Use -fallback-style=none to skip formatting.
69 --ferror-limit=<uint> - Set the maximum number of clang-format errors to emit
79 -length, clang-format will format up to the end
82 --lines=<string> - <start line>:<end line> - format a range of
94 --qualifier-alignment=<string> - If set, overrides the qualifier alignment style
95 determined by the QualifierAlignment style flag
97 determined by the SortIncludes style flag
98 --style=<string> - Set coding style. <string> can be:
101 2. 'file' to load style configuration from a
102 .clang-format file in one of the parent directories
104 If no .clang-format file is found, falls back to
105 --fallback-style.
106 --style=file is the default.
110 --style="{BasedOnStyle: llvm, IndentWidth: 8}"
122 When the desired code formatting style is different from the available options,
123 the style can be customized using the ``-style="{key: value, ...}"`` option or
124 by putting your style configuration in the ``.clang-format`` or ``_clang-format``
125 file in your project's directory and using ``clang-format -style=file``.
127 An easy way to create the ``.clang-format`` file is:
131 clang-format -style=llvm -dump-config > .clang-format
133 Available style options are described in :doc:`ClangFormatStyleOptions`.
140 :program:`clang-format` standalone tool on your current buffer, optionally
142 which can be found under `clang/tools/clang-format/clang-format.py`.
148 map <C-K> :pyf <path-to-this-file>/clang-format.py<cr>
149 imap <C-K> <c-o>:pyf <path-to-this-file>/clang-format.py<cr>
151 The first line enables :program:`clang-format` for NORMAL and VISUAL mode, the
153 you need :program:`clang-format` on a different key (C-K stands for Ctrl+k).
155 With this integration you can press the bound key and clang-format will
156 format the current line in NORMAL and INSERT mode or the selected region in
163 An alternative option is to format changes when saving a file and thus to
171 pyf <path-to-this-file>/clang-format.py
180 :program:`emacs`. It can be found at `clang/tools/clang-format/clang-format.el`
185 (load "<path-to-clang>/tools/clang-format/clang-format.el")
186 (global-set-key [C-M-tab] 'clang-format-region)
188 This binds the function `clang-format-region` to C-M-tab, which then formats the
195 :program:`clang-format` cannot be used as a text filter with BBEdit, but works
197 `clang/tools/clang-format/clang-format-bbedit.applescript`; place a copy in
199 point to your local copy of :program:`clang-format`.
202 :program:`clang-format` will format the selection. Note that you can rename the
210 :program:`clang-format` is integrated into `CLion <https://www.jetbrains
212 automatically when there is a ``.clang-format`` file under the project root.
213 Code style rules are applied as you type, including indentation,
216 :program:`clang-format` can also be enabled without a ``.clang-format`` file.
218 or the default LLVM style.
231 …arketplace <https://marketplace.visualstudio.com/items?itemName=xaver.clang-format>`_. The default…
236 The script `clang/tools/clang-format/git-clang-format` can be used to
237 format just the lines touched in git commits:
241 % git clang-format -h
242 usage: git clang-format [OPTIONS] [<commit>] [<commit>|--staged] [--] [<file>...]
244 If zero or one commits are given, run clang-format on all lines that differ
249 To format staged changes, i.e everything that's been `git add`ed:
250 git clang-format
252 To also format everything touched in the most recent commit:
253 git clang-format HEAD~1
255 If you're on a branch off main, to format everything touched on your branch:
256 git clang-format main
258 If two commits are given (requires --diff), run clang-format on all lines in the
265 clangFormat.style
273 --binary BINARY path to clang-format
278 … comma-separated list of file extensions to format, excluding the period and case-insensitive
282 --staged, --cached format lines in the stage instead of the working dir
283 --style STYLE passed to clang-format
290 The python script `clang/tools/clang-format/clang-format-diff.py` parses the
292 :program:`clang-format`.
296 …usage: clang-format-diff.py [-h] [-i] [-p NUM] [-regex PATTERN] [-iregex PATTERN] [-sort-includes]…
297 [-fallback-style FALLBACK_STYLE] [-binary BINARY]
303 git diff -U0 --no-color --relative HEAD^ | clang-format-diff.py -p1 -i
304 svn diff --diff-cmd=diff -x-U0 | clang-format-diff.py -i
317 -sort-includes let clang-format sort include blocks
319 …-style STYLE formatting style to apply (LLVM, GNU, Google, Chromium, Microsoft, Mozilla, …
320 -fallback-style FALLBACK_STYLE
321 …The name of the predefined style used as a fallback in case clang-format is invoked with-style=fil…
322 find the .clang-formatfile to use.
323 -binary BINARY location of binary to use for clang-format
329 hg diff -U0 --color=never | clang-format-diff.py -i -p1
331 The option `-U0` will create a diff without context lines (the script would format
340 The following table :doc:`ClangFormattedStatus` shows the current status of clang-formatting for th…