【问题标题】:Merlin plugin for Ocaml with VIM : autocompile the file when saving带有 VIM 的 Ocaml 的 Merlin 插件:保存时自动编译文件
【发布时间】:2018-07-07 15:07:32
【问题描述】:

我最近为一门大学课程安装了 Ocaml 及其 Merlin 插件。我使用 Vim 作为文本编辑器。我听说可以将 Merlin 配置为在保存时自动编译 .ml 文件,但我无法通过网络研究找到任何相关信息,而且教授正在使用 emacs,所以他无法给我任何有关如何编译的信息激活此功能。

【问题讨论】:

  • 如何编译 ml 文件。你在 CLI 中使用makefile 还是普通的ocaml
  • 我使用类似于ocamlopt -o helloWorld helloWorld.ml的命令,然后是./helloWorld

标签: vim ocaml merlin


【解决方案1】:

这是普通的 vim 风格,与 merlin 无关。可能您可以阅读 merlin 文档以了解 merlin 特定配置。在您的~/.vimrc 中设置以下内容

使用F5之类的键来实现

autocmd filetype ocaml nnoremap <F5> :!ocamlopt % -o %:r && ./%:r <CR>

当您点击 F5 时,这将编译并运行可执行文件。


如果您更喜欢makeprg 选项,请在您的vimrc 中保留以下自动命令

au filetype ocaml set makeprg=ocamlopt\ -o\ %<\ %
set aw

然后是:make,当您打开您的 ml 文件时。我更喜欢这种方法

【讨论】:

    猜你喜欢
    • 2018-12-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-14
    • 2017-03-30
    • 1970-01-01
    相关资源
    最近更新 更多