• Home
  • Raw
  • Download

Lines Matching +full:clang +full:- +full:format

13 :program:`clang-format` is located in `clang/tools/clang-format` and can be used
14 to format C/C++/Obj-C code.
16 .. code-block:: console
18 $ clang-format -help
19 OVERVIEW: A tool to format C/C++/Java/JavaScript/Objective-C/Protobuf code.
23 If <file>s are given, it reformats the files. If -i is specified
24 together with <file>s, the files are edited in-place. Otherwise, the
27 USAGE: clang-format [options] [<file> ...]
31 Clang-format options:
33 -assume-filename=<string> - When reading from stdin, clang-format assumes this
35 -style=file) and to determine the language.
36 -cursor=<uint> - The position of the cursor when invoking
37 clang-format from an editor integration
38 -dump-config - Dump configuration options to stdout and exit.
39 Can be used with -style option.
40 -fallback-style=<string> - The name of the predefined style used as a
41 fallback in case clang-format is invoked with
42 -style=file, but can not find the .clang-format
44 Use -fallback-style=none to skip formatting.
45 -i - Inplace edit <file>s, if specified.
46 -length=<uint> - Format a range of this length (in bytes).
48 several -offset and -length pairs.
49 When only a single -offset is specified without
50 -length, clang-format will format up to the end
53 -lines=<string> - <start line>:<end line> - format a range of
54 lines (both 1-based).
56 several -lines arguments.
57 Can't be used with -offset and -length.
59 -offset=<uint> - Format a range starting at this byte offset.
61 several -offset and -length pairs.
63 -output-replacements-xml - Output replacements as XML.
64 -sort-includes - Sort touched include lines
65 -style=<string> - Coding style, currently supports:
67 Use -style=file to load style configuration from
68 .clang-format file located in one of the parent
71 Use -style="{key: value, ...}" to set specific
73 -style="{BasedOnStyle: llvm, IndentWidth: 8}"
77 -help - Display available options (-help-hidden for more)
78 -help-list - Display list of available options (-help-list-hidden for more)
79 -version - Display the version of this program
83 the style can be customized using the ``-style="{key: value, ...}"`` option or
84 by putting your style configuration in the ``.clang-format`` or ``_clang-format``
85 file in your project's directory and using ``clang-format -style=file``.
87 An easy way to create the ``.clang-format`` file is:
89 .. code-block:: console
91 clang-format -style=llvm -dump-config > .clang-format
100 :program:`clang-format` standalone tool on your current buffer, optionally
101 selecting regions to reformat. The integration has the form of a `python`-file
102 which can be found under `clang/tools/clang-format/clang-format.py`.
106 .. code-block:: vim
108 map <C-K> :pyf <path-to-this-file>/clang-format.py<cr>
109 imap <C-K> <c-o>:pyf <path-to-this-file>/clang-format.py<cr>
111 The first line enables :program:`clang-format` for NORMAL and VISUAL mode, the
112 second line adds support for INSERT mode. Change "C-K" to another binding if
113 you need :program:`clang-format` on a different key (C-K stands for Ctrl+k).
115 With this integration you can press the bound key and clang-format will
116 format the current line in NORMAL and INSERT mode or the selected region in
128 :program:`emacs`. It can be found at `clang/tools/clang-format/clang-format.el`
131 .. code-block:: common-lisp
133 (load "<path-to-clang>/tools/clang-format/clang-format.el")
134 (global-set-key [C-M-tab] 'clang-format-region)
136 This binds the function `clang-format-region` to C-M-tab, which then formats the
143 :program:`clang-format` cannot be used as a text filter with BBEdit, but works
145 `clang/tools/clang-format/clang-format-bbedit.applescript`; place a copy in
147 point to your local copy of :program:`clang-format`.
150 :program:`clang-format` will format the selection. Note that you can rename the
159 <http://llvm.org/builds/>`_. The default key-binding is Ctrl-R,Ctrl-F.
165 The python script `clang/tools/clang-format-diff.py` parses the output of
166 a unified diff and reformats all contained lines with :program:`clang-format`.
168 .. code-block:: console
170 usage: clang-format-diff.py [-h] [-i] [-p NUM] [-regex PATTERN] [-style STYLE]
172 Reformat changed lines in diff. Without -i option just output the diff that
176 -h, --help show this help message and exit
177 -i apply edits to files instead of displaying a diff
178 -p NUM strip the smallest prefix containing P slashes
179 -regex PATTERN custom pattern selecting file paths to reformat
180 -style STYLE formatting style to apply (LLVM, Google, Chromium, Mozilla,
185 .. code-block:: console
187 git diff -U0 HEAD^ | clang-format-diff.py -i -p1
191 .. code-block:: console
193 svn diff --diff-cmd=diff -x -U0 | clang-format-diff.py -i
195 The option `-U0` will create a diff without context lines (the script would format