Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to indent existing OCaml code

I have ~30.000 lines of badly indented OCaml code (including mly and mll files) and would like to indent them. I tried googling for variations of 'ocaml indent' the closest I can get is to use Omlet.vim and indent the code one line at a time (via C-f in insert mode). Is there a way to do the indentation for all the 30000 lines?

like image 676
vbigiani Avatar asked Dec 17 '09 22:12

vbigiani


1 Answers

I use Emacs as my editor with this package installed:

http://caml.inria.fr/pub/docs/u3-ocaml/emacs/index.html

To indent existing code you need to highlight it and then use the key combination C-M-\

You can script this per file pretty easily and I find the indentation to be pretty good.

like image 156
chollida Avatar answered Nov 17 '22 18:11

chollida