Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Indentation tool for OCaml, to be used from editors like Emacs and Vim.

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.


A simple tool to indent OCaml programs

Authors: Louis Gesbert (OCamlPro), Thomas Gazagnaire (OCamlPro), Jun Furuse

License: GPL v3.0


You need OCaml and ocp-build installed to compile ocp-indent.

make install

If you use opam and want it installed alongside ocaml, you may want to use ./configure --prefix $(opam config -var prefix).


  • ocp-indent or ocp-indent < outputs the file re-indented
  • From emacs, load emacs.el to have tuareg-mode automatically use ocp-indent. Warning: it is in a very early stage, intended for testing and debug only.
  • From emacs, you can also do a quick test with C-u M-| ocp-indent

These options should be mostly useful for binding in editors:

  • ocp-indent --lines <m>-<n> reindents only from line <m> to line <n>
  • ocp-indent --numeric only outputs the indentation values as integers, for the lines that should be reindented.


  • tests/passing contains tests that are properly indented and should be left unchanged by ocp-indent.
  • tests/failing contains tests for which ocp-indent currently returns the results in tests/failing-output, hence meld tests/failing{,-output} should give an overview of currently known bugs.
  • tests/ checks the current state against the reference state (checked into git).
  • tests/ --[git-]update updates the current reference state.
  • See tests/ --help for more

Please make sure tu run make && tests/ --git-update before any commit, so that the repo always reflects the state of the program.

Configuration options

A proper configuration engine is being written. For the time being you can use a few environment variables defined at the beginning of src/ of most use should be match_clause_indent (usually 2 or 4, default is 2) and type_indent.

Something went wrong with that request. Please try again.