Distributed by, announced on Freshmeat.

Fans of both Caml and Vim will be happy to hear that Emacs is no more the only editor with a decent indentation for their favorite language. Try OMLet, and please feedback! Here is an example of what it does, and here is a more realistic one.

OMLet is already packaged in Debian's ocaml-tools, in the unstable version. And it will be distributed soon directly with VIm as the default OCaml mode.




Please make sure that the following line is in your ~/.vimrc, otherwise indentation won't be loaded automatically: filetype plugin indent on


OMLet indentation can be customized by setting a few variables. This setting is usually done by adding a line like let variable = value in your .vimrc. For the general variables, only the existence of a binding is taken into account, not the value:

For indentation, the value matters:

I also recently added omlet_middle_comment, a boolean (0/1) for choosing whether or not you want * at every new line in your comments. Auto indentation still has problems with this, but reindenting works.

Here is a commented example:

(* Default setting, everything set to 2. Notations: * omlet_indent: _ * omlet_indent_let: . * omlet_indent_match: ~ * omlet_indent_function: - * omlet_indent_struct: , *) module Example = struct ,,let top = __let x = 1 in let y = 3 in ..baz foo __bar ; match x with ~~| Foo -> (function x --| Foo -> Bar --| Bar -> Foo) ~~| Bar -> (fun x -> x) end

Working with other people

If you work with somebody else using OMLet, it is a good idea to add an OCaml modeline to your files. Then, OMLet's customization will be the same for everybody. Also, it would be very nice if somebody write an OCaml modeline parser for Emacs/Tuareg. Here is the OCaml modeline syntax:

"(*:" "o"?"caml:" (param "=" value)* "*)"

For example:

(*:caml: let=0 match=0 *)

The available parameters are default, let, match, fun, struct, and you guess their meaning.

Omlet indents with spaces, so if you want a full compatibility with emacs's tuareg-mode, it is recommended to use space-only indentation with emacs: (setq-default indent-tabs-mode nil)

Misc tips

Key mappings are prefixed by <LocalLeader>, which defaults to '\'. If you find something like '.' or ',' more accessible, customize your .vimrc: let maplocalleader="."

If you've been using emacs for a while, you might be a tab addict. Adding the following line to your .vimrc will make tab run indentation when hit in insert mode (C-f is the default for that in VIm): autocmd FileType omlet set indentkeys+=,!^I

I also recommend using otags in order to have tags working on OCaml projects.

Why expand tabs ?