1OCP-INDENT(1)                  Ocp-indent Manual                 OCP-INDENT(1)
2
3
4

NAME

6       ocp-indent - Automatic indentation of OCaml source files
7

SYNOPSIS

9       ocp-indent [OPTION]... [FILE]...
10

DESCRIPTION

12       Indent OCaml source files according to the official conventions, with a
13       small number of tunable parameters.
14
15       Outputs the indented version of each FILE given in the command line to
16       standard output, unless invoked with the `--inplace' option (see
17       OPTIONS below). If no FILE is provided, reads from standard input.
18

CONFIGURATION

20       Parameters can be defined on the command-line via the --config option,
21       or as a configuration definition in one of the following, searched in
22       order: a file named `.ocp-indent' in the current directory or its
23       parents (which allows for per-project indentation settings), the file
24       `$XDG_CONFIG_HOME/ocp/ocp-indent.conf', the file
25       `$HOME/.ocp/ocp-indent.conf', or the environment variable
26       $OCP_INDENT_CONFIG.
27
28       A configuration definition is a list of bindings in the form NAME=VALUE
29       or of PRESET, separated by commas or newlines
30
31       Syntax: [PRESET,]VAR=VALUE[,VAR=VALUE...]
32
33       base=INT (default=2)
34           Indentation used when none of the following options applies.
35
36               let foo =
37               ..bar
38
39       type=INT (default=2)
40           Indentation for type definitions.
41
42               type t =
43               ..int
44
45       in=INT (default=0)
46           Indentation after `let ... in', unless followed by another `let'.
47
48               let foo = () in
49               ..bar
50
51       with=INT (default=0)
52           Indentation after `match ... with', `try ... with' or `function'.
53
54               match foo with
55               ..| _ -> bar
56
57       match_clause=INT (default=2)
58           Indentation for clauses inside a pattern-match (after arrows).
59
60               match foo with
61               | _ ->
62               ..bar
63
64       ppx_stritem_ext=INT (default=2)
65           Indentation for items inside a [%%id ... ] extension node).
66
67               [%% id.id
68               ..let x = 3 ]
69
70       max_indent=<INT|none> (default=4)
71           When nesting expressions on the same line, their indentations are
72           stacked in some cases so that they remain correct if you close them
73           one per line. However, this can lead to large indentations in
74           complex code, so this parameter sets a maximum indentation. Note
75           that it only affects indentation after function arrows and opening
76           parens at the ends of lines.
77
78               let f = g (h (i (fun x ->
79               ....x)
80                 )
81               )
82
83       strict_with=<always|never|auto> (default=never)
84           If `never', match bars are indented, superseding `with', whenever
85           `match with' doesn't start its line. If `auto', there are
86           exceptions for constructs like `begin match with'. If `always',
87           `with' is always strictly respected, and additionally applies to
88           variant types definition, for consistency.
89
90           Example with `strict_with=never,with=0':
91               begin match foo with
92               ..| _ -> bar
93               end
94
95       strict_else=<always|never|auto> (default=always)
96           If `always', indent after the `else' keyword normally, like after
97           `then'. If `auto', indent after `else' unless in a few "unclosable"
98           cases (`let .... in', `match', etc.). If `never', the `else'
99           keyword won't indent when followed by a newline.
100
101           Example with `strict_else=auto':
102               if cond then
103                 foo
104               else
105               let x = bar in
106               baz
107
108       strict_comments=BOOL (default=false)
109           In-comment indentation is normally preserved, as long as it
110           respects the left margin or the comments starts with a newline.
111           Setting this to `true' forces alignment within comments. Lines
112           starting with `*' are always aligned
113
114       align_ops=BOOL (default=true)
115           Toggles preference of column-alignment over line indentation for
116           most of the common operators and after mid-line opening
117           parentheses.
118
119           Example with `align_ops=true':
120               let f x = x
121                         + y
122        
123           Example with `align_ops=false':
124               let f x = x
125                 + y
126
127       align_params=<always|never|auto> (default=auto)
128           If `never', function parameters are indented one level from the
129           line of the function. If `always', they are aligned from the column
130           of the function. if `auto', alignment is chosen over indentation in
131           a few cases, e.g. after match arrows
132
133           Example with `align_params=never':
134               match foo with
135               | _ -> some_fun
136                 ..parameter
137        
138           Example with `align_params=always' or `auto':
139               match foo with
140               | _ -> some_fun
141                      ..parameter
142
143       Available presets are `normal', the default, `apprentice' which may
144       make some aspects of the syntax more obvious for beginners, and
145       `JaneStreet'.
146

OPTIONS

148       -c CONFIG, --config=CONFIG
149           Configure the indentation parameters. See section CONFIGURATION for
150           more information.
151
152       -d, --debug
153           Enable debug output to stderr.
154
155       --help[=FMT] (default=auto)
156           Show this help in format FMT. The value FMT must be one of `auto',
157           `pager', `groff' or `plain'. With `auto', the format is `pager` or
158           `plain' whenever the TERM env var is `dumb' or undefined.
159
160       -i, --inplace
161           Re-indent files in-place.
162
163       --indent-empty
164           Return indent for empty lines, too. Especially usefull with
165           --numeric.
166
167       -l RANGE, --lines=RANGE (absent=-)
168           Only re-indent the lines in RANGE (eg. 10-12), adapting to the
169           current indentation of surrounding lines. Lines start at 1.
170
171       --load-mods=VAL
172           Load plugins.
173
174       --load-pkgs=VAL
175           Load plugins.
176
177       --numeric
178           Instead of re-indenting the file, output one integer per line
179           representing the indentation value. When specified together with
180           --lines, only print as many values as lines in the range.
181
182       -o FILE, --output=FILE
183           Output to FILE. The default is to print to stdout.
184
185       --print-config
186           Print the current parameters to stdout and exit. (See section
187           CONFIGURATION for more information.)
188
189       --syntax=VAL
190           Extend the handled syntax for OCaml syntax extensions.
191
192       --version
193           Show version information.
194

BUGS

196       Bugs are tracked on github at
197       https://github.com/OCamlPro/ocp-indent/issues. The tests directory of
198       the source distribution is a good snapshot of the current status, and
199       can be checked online at
200       http://htmlpreview.github.io/?https://github.com/OCamlPro/ocp-indent/blob/master/tests/failing.html
201

SEE ALSO

203       ocaml(1), ocp-index(1)
204

AUTHORS

206       Louis Gesbert and Thomas Gazagnaire from OCamlPro, from an original
207       prototype by Jun Furuse.
208

LICENSE

210       Copyright (C) 2013 OCamlPro.
211
212       ocp-indent is free software, released under the terms of the GNU
213       General Public License version 3, the text of which can be found in the
214       file `LICENSE' distributed with the sources.
215
216
217
218Ocp-indent 1.8.1                                                 OCP-INDENT(1)
Impressum