OCP-INDENT(1)
✨ OCP-INDENT(1) — the Ocp-indent Manual page, but make it make sense ✨
okay so bestie, welcome to the ocp-indent manual page, from the Ocp-indent Manual fam 💅 this is the whole thing, translated into something a human can actually vibe with. no facts were harmed in the making of this.
🌸 NAME 🌸
ocp-indent — automatic indentation of OCaml source files. yes. it does your indenting for you. it's giving "my code is a mess but make it fashion" 💖
🦋 SYNOPSIS 🦋
ocp-indent [OPTION]… [FILE]…
✨ DESCRIPTION ✨
It indents your OCaml source files according to the official conventions, and there are like a small number of tunable parameters so you can make it match your personal ~aesthetic~.
It writes the indented version of every FILE you hand it on the command line straight to standard output — unless you invoke it with --inplace (go peek at OPTIONS below 👀). And if you pass no FILE at all, it just reads from standard input. lowkey cozy.
🎀 CONFIGURATION 🎀
You can set parameters on the command line with the --config option, or you can define a configuration in one of these bad boys. They get searched in this order, so pay attention:
- a file named
.ocp-indentin the current directory or its parents — this is the per-project indentation settings slay, love that for you - the file
$XDG_CONFIG_HOME/ocp/ocp-indent.conf - the file
$HOME/.ocp/ocp-indent.conf - the environment variable
$OCP_INDENT_CONFIG
A configuration definition is a list of bindings shaped like NAME=VALUE, or of PRESET, separated by commas or newlines.
Syntax go brrr:
[PRESET,]VAR=VALUE[,VAR=VALUE...]
base=INT — default 2
The indentation used when none of the options below apply, i.e. the fallback queen 👑
��������let foo =
��������..bar
type=INT — default 2
Indentation for type definitions. type girlies, this one's for you.
��������type t =
��������..int
in=INT — default 0
Indentation after let ... in, unless it's followed by another let.
��������let foo = () in
��������..bar
with=INT — default 0
Indentation after match ... with, try ... with or function.
��������match foo with
��������..| _ -> bar
match_clause=INT — default 2
Indentation for the clauses inside a pattern-match (so like, after the arrows).
��������match foo with
��������| _ ->
��������..bar
ppx_stritem_ext=INT — default 2
Indentation for items inside a [%%id ... ] extension node.
��������[%% id.id
��������..let x = 3 ]
max_indent=<INT|none> — default 4
so when you nest expressions on the same line, their indentations get stacked in some cases — that way they stay correct if you close them one per line. cute in theory! but it can lead to huge indentations in complex code 😭 so this parameter caps it at a maximum. heads up tho: it only affects indentation after function arrows and opening parens at the ends of lines. nothing else. periodt.
��������let f = g (h (i (fun x ->
��������....x)
����������)
��������)
strict_with=<always|never|auto> — default never
never: match bars get indented, supersedingwith, whenevermatch withdoesn't start its own line.auto: there are exceptions, e.g. for constructs likebegin match with.always:withis always strictly respected — and it additionally applies to variant type definitions, for consistency.
Example with strict_with=never,with=0:
��������begin match foo with
��������..| _ -> bar
��������end
strict_else=<always|never|auto> — default always
always: indent after theelsekeyword normally, exactly like afterthen.auto: indent afterelseunless you're in one of a few "unclosable" cases (let .... in,match, etc.).never: theelsekeyword won't indent when it's followed by a newline.
Example with strict_else=auto:
��������if cond then
����������foo
��������else
��������let x = bar in
��������baz
strict_comments=BOOL — default false
In-comment indentation is normally preserved — as long as it respects the left margin or the comment starts with a newline. Setting this to true forces alignment within comments. Lines starting with * are always aligned, no matter what.
align_ops=BOOL — default true
Toggles the preference for column-alignment over line indentation, for most of the common operators and after mid-line opening parentheses. basically: do you want it lined up or just pushed in.
Example with align_ops=true:
��������let f x = x
������������������+ y
Example with align_ops=false:
��������let f x = x
����������+ y
align_params=<always|never|auto> — default auto
never: function parameters are indented one level from the line of the function.always: they get aligned from the column of the function instead.auto: alignment is chosen over indentation in a few cases, e.g. after match arrows.
Example with align_params=never:
��������match foo with
��������| _ -> some_fun
����������..parameter
Example with align_params=always or auto:
��������match foo with
��������| _ -> some_fun
���������������..parameter
match_tail_cascade=BOOL — default false
If true, the default indentation is suppressed for matches that directly follow a match arrow. This avoids shifting everything to the right when matches eliminate specific cases in succession — which Gabriel Scherer coined as the "cascading style", as opposed to the usual "nesting style". This is similar to what happens with strict_else=auto. iykyk 🌀
Example with match_tail_cascade=true:
��������match foo with
��������| Error err -> fail_foo_error err
��������| Ok y ->
����������match bar y with
��������| Error err ->
The available presets are:
normal— the default, the standard slayapprentice— may make some aspects of the syntax more obvious for beginners 🧚JaneStreet— you already know
💅 OPTIONS 💅
-c CONFIG,--config=CONFIG— configure the indentation parameters. See section CONFIGURATION up there for the tea.-d,--debug— enable debug output to stderr.-i,--inplace— re-indent the files in place. it edits your actual files, bestie, be aware.--indent-empty— return indent for empty lines too. especially usefull with--numeric. (yes that's how it's spelled, we're keeping it)-l RANGE,--lines=RANGE— absent by default and shown as(absent=-). Only re-indent the lines inRANGE(eg.10-12), adapting to the current indentation of the surrounding lines. Lines start at1.--load-mods=VAL— load plugins.--load-pkgs=VAL— load plugins. (yes, again, it really does say that)--numeric— instead of re-indenting the file, output one integer per line representing the indentation value. When specified together with--lines, only print as many values as lines in the range. numbers only, no notes.-o FILE,--output=FILE— output toFILE. The default is to print to stdout.--print-config— print the current parameters to stdout and exit. (See section CONFIGURATION for more.)--syntax=VAL— extend the handled syntax for OCaml syntax extensions.
🌈 COMMON OPTIONS 🌈
--help[=FMT]— defaultauto. Show this help in formatFMT. The valueFMTmust be one ofauto,pager,grofforplain. Withauto, the format ispagerorplainwhenever theTERMenv var isdumbor undefined.--version— show version information.
⭐ EXIT STATUS ⭐
ocp-indent exits with the following status, so you can decode the vibe check:
0— on success 🎉123— on indiscriminate errors reported on standard error124— on command line parsing errors125— on unexpected internal errors (bugs) 💀
🐛 BUGS 🐛
Bugs are tracked on github at https://github.com/OCamlPro/ocp-indent/issues. The tests directory of the source distribution is a good snapshot of the current status, and you can check it online at http://htmlpreview.github.io/?https://github.com/OCamlPro/ocp-indent/blob/master/tests/failing.html 🫶
👑 SEE ALSO 👑
🍓 AUTHORS 🍓
Louis Gesbert and Thomas Gazagnaire from OCamlPro, from an original prototype by Jun Furuse. icons only.
💜 LICENSE 💜
Copyright (C) 2013 OCamlPro.
ocp-indent is free software, released under the terms of the GNU General Public License version 3, the text of which can be found in the file LICENSE distributed with the sources.
okay that's the whole page, mwah 💋 this was Ocp-indent version 1.9.0, page OCP-INDENT(1) — go indent something iconic 🦋✨
📦 where this page comes from
- alpine 3.24: ocp-indent-doc 1.9.0-r3 · LGPL-2.1-only WITH OCaml-LGPL-linking-exception
- 💖 girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms