I recently installed Ocaml and its Merlin plugin for a university course. I am using Vim as a text editor. I have heard that it is possible to configure Merlin to compile automatically the .ml file when saving, but I can not find anything about that with a web research, and the professor is using emacs so he can not give me any information about how to activate this feature.
This is plain vanilla vim style, not relating to merlin. May be you can read merlin document for merlin specific configuration. Set the following in your ~/.vimrc
Use a key like F5 to achieve it
autocmd filetype ocaml nnoremap <F5> :!ocamlopt % -o %:r && ./%:r <CR>
This will compile and run executable when you hit F5.
If you prefer makeprg
option, keep the following autocommand in your vimrc
au filetype ocaml set makeprg=ocamlopt\ -o\ %<\ %
set aw
and then :make
when you open your ml file. I would prefer this approach