# OCaml, VIM, Repl

**URL:** <https://discuss.ocaml.org/t/ocaml-vim-repl/4049>\
**Category:** Community\
**Created:** [July 6, 2019, 2:53am UTC](https://discuss.ocaml.org/t/ocaml-vim-repl/4049 "2019-07-06T02:53:54Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![zeroexcuses](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/zeroexcuses/32/1692_2.png) [@zeroexcuses](https://discuss.ocaml.org/u/zeroexcuses)\
**Post date:** [July 6, 2019, 2:53am UTC](https://discuss.ocaml.org/t/ocaml-vim-repl/4049/1 "2019-07-06T02:53:54Z")

</div>

I’m currently following [https://github.com/ocaml/merlin/wiki/vim-from-scratch](https://github.com/ocaml/merlin/wiki/vim-from-scratch) for my OCaml / Merlin / VIM setup.

One thing I’m missing right now is OCaml REPL \<-\> VIM integration. I’m looking for something where:

1. we start a OCaml REPL from some project
2. we can type directly into the REPL
3. we can send current VIM buffer to REPL
4. we can send last OCaml to REPL

Any pointers?

---

<div class="post-metadata">

**Author:** ![n4323](https://avatars.discourse-cdn.com/v4/letter/n/97f17d/32.png) [@n4323](https://discuss.ocaml.org/u/n4323)\
**Post date:** [July 8, 2019, 8:37am UTC](https://discuss.ocaml.org/t/ocaml-vim-repl/4049/2 "2019-07-08T08:37:46Z")

</div>

I use [https://github.com/jpalardy/vim-slime](https://github.com/jpalardy/vim-slime) together with tmux for sending vim buffer contents to utop. I.e. I manually start utop within a tmux session, then configure vim-slime for that session, and send stuff from vim to tmux with `<c-c><c-c>`. vim-slime works also for other terminal multiplexers, see the docs.  
I don’t understand your point 4.

---

<div class="post-metadata">

**Author:** ![bluddy](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/bluddy/32/104_2.png) [@bluddy](https://discuss.ocaml.org/u/bluddy)\
**Post date:** [July 8, 2019, 11:55pm UTC](https://discuss.ocaml.org/t/ocaml-vim-repl/4049/3 "2019-07-08T23:55:50Z")

</div>

Both neovim and vim now have terminal emulators integrated into them, though I hear neovim’s is a little more stable. You might want to look into this, as it’d allow you to use vim’s regular copy-paste to copy into the REPL.

---

<div class="post-metadata">

**Author:** ![n4323](https://avatars.discourse-cdn.com/v4/letter/n/97f17d/32.png) [@n4323](https://discuss.ocaml.org/u/n4323)\
**Post date:** [July 9, 2019, 9:07am UTC](https://discuss.ocaml.org/t/ocaml-vim-repl/4049/4 "2019-07-09T09:07:14Z")

</div>

I haven’t used it but it seems vim-slime can also target the terminal emulators in new vim and in neovim versions – i guess then it mainly provides a useful shortcut for copy and paste and perhaps some automatic appending of `;;` etc.

---

<div class="post-metadata">

**Author:** ![thangngoc89](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/thangngoc89/32/673_2.png) [@thangngoc89](https://discuss.ocaml.org/u/thangngoc89)\
**Post date:** [July 9, 2019, 11:31am UTC](https://discuss.ocaml.org/t/ocaml-vim-repl/4049/5 "2019-07-09T11:31:57Z")

</div>

After working with Toploop for awhile, I think that ;; is just a limitation of the terminal UI. if you can distinguish between Enter and Shift + Enter, you can make ;; optional.

---

<div class="post-metadata">

**Author:** ![Leonidas](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/leonidas/32/4039_2.png) [@Leonidas](https://discuss.ocaml.org/u/Leonidas)\
**Post date:** [July 9, 2019, 1:30pm UTC](https://discuss.ocaml.org/t/ocaml-vim-repl/4049/6 "2019-07-09T13:30:05Z")

</div>

@jeremiedimino mentioned that there is a [workaround](https://discuss.ocaml.org/t/double-semicolon-peculiarity/1261/16) to automatically insert `;;`.

---

<div class="post-metadata">

**Author:** ![Chris00](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/chris00/32/48_2.png) [@Chris00](https://discuss.ocaml.org/u/Chris00)\
**Post date:** [July 9, 2019, 2:29pm UTC](https://discuss.ocaml.org/t/ocaml-vim-repl/4049/7 "2019-07-09T14:29:06Z")

</div>

> [@thangngoc89](#):
>
> if you can distinguish between Enter and Shift + Enter, you can make ;; optional.

If you use [Tuareg](https://github.com/ocaml/tuareg), you can just type Sift-return to evaluate your phrase.

---

<div class="post-metadata">

**Author:** ![thangngoc89](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/thangngoc89/32/673_2.png) [@thangngoc89](https://discuss.ocaml.org/u/thangngoc89)\
**Post date:** [July 9, 2019, 3:39pm UTC](https://discuss.ocaml.org/t/ocaml-vim-repl/4049/8 "2019-07-09T15:39:28Z")

</div>

yeah. That’s basically what I’m saying. because the terminal can’t distinguish between different combinations, ;; is needed
