Sublime Forum

OCaml indentation

#1

I wanted to type the following OCaml code:

let f x = if x = 0 then () else ...
However, as soon as I press the last “e” in “else”, Sublime moves the “else” backwards, making the code appear as follows:

let f x = if x = 0 then () else
Sometimes the same happens with the “done” keyword as well.
How can I change this behavior so that the keywords stay where I typed them?

(I use Sublime Text 3 with tab width=4, indent using spaces, and all settings regarding indents (e.g. auto_indent and smart_indent) are using default values)

0 Likes

#2

Here is how I solved it:

  1. Install PackageResourceViewer
  2. command palette, PackageResourceViewer: Open resource, select the OCaml package, and then the “Indent rules” file
  3. edit the file, for example removing else from decreaseIndentPattern
  4. save the file, and PackageResourceViewer will save it as a local override; you can open it again in the future using the same Open resource command.
1 Like

#3

feel free to make a PR at https://github.com/sublimehq/Packages if you think it will benefit others

1 Like