Once line breaks are inserted, one can use ocp-indent to properly indent OCaml code. Is there a tool to insert line breaks (somehow) to OCaml code that are written with insufficient (or no) line breaks? I could think of writing a compiler (using compiler-libs) that parses the input and immediately pretty print it, but that would remove all the comments in the program. -- Kenichi Asai
https://github.com/ocaml-ppx/ocamlformat is not exactly what you are asking for but might fit the bill - Basile On Fri, 2021-06-11 at 15:18 +0900, Kenichi Asai wrote: > Once line breaks are inserted, one can use ocp-indent to properly > indent OCaml code. Is there a tool to insert line breaks (somehow) to > OCaml code that are written with insufficient (or no) line breaks? > > I could think of writing a compiler (using compiler-libs) that parses > the input and immediately pretty print it, but that would remove all > the comments in the program. >
On 11/06/2021 15:18, Kenichi Asai wrote: > Once line breaks are inserted, one can use ocp-indent to properly > indent OCaml code. Is there a tool to insert line breaks (somehow) to > OCaml code that are written with insufficient (or no) line breaks? The unix command 'fmt --width 80' might fill the bill. No? > I could think of writing a compiler (using compiler-libs) that parses > the input and immediately pretty print it, but that would remove all > the comments in the program.