# Open up vim instance to write, then save the text to a variable?

**URL:** <https://discourse.julialang.org/t/open-up-vim-instance-to-write-then-save-the-text-to-a-variable/38047>\
**Category:** Tooling\
**Created:** [April 22, 2020, 10:01pm UTC](https://discourse.julialang.org/t/open-up-vim-instance-to-write-then-save-the-text-to-a-variable/38047 "2020-04-22T22:01:58Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [April 22, 2020, 10:01pm UTC](https://discourse.julialang.org/t/open-up-vim-instance-to-write-then-save-the-text-to-a-variable/38047/1 "2020-04-22T22:01:58Z")

</div>

When I do `git commit`, Git opens up a little Vim instance. Then I write in it and when I pres `:wq`, Git saves that text and it becomes the commit message.

Is there any way to have such a workflow within julia? Not related to Git at all, just something to capture user input in a way that gives a bit more flexibility than `readline()`.

---

<div class="post-metadata">

**Author:** ![tbeason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tbeason/32/15898_2.png) [@tbeason](https://discourse.julialang.org/u/tbeason)\
**Post date:** [April 22, 2020, 10:17pm UTC](https://discourse.julialang.org/t/open-up-vim-instance-to-write-then-save-the-text-to-a-variable/38047/2 "2020-04-22T22:17:31Z")

</div>

Can you elaborate more on what you have in mind?

Like, at this point, my suggestion is to use `; vim` from the REPL. That is still “within” Julia to some extent, yea?

---

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [April 22, 2020, 10:20pm UTC](https://discourse.julialang.org/t/open-up-vim-instance-to-write-then-save-the-text-to-a-variable/38047/3 "2020-04-22T22:20:06Z")

</div>

I want to be able to, after a prompt, write multiple lines, then when I close that small editor, julia saves the string of whatever I wrote as a string.

So accessing `; vim` would be fine if I could press `:wq` when I’m done and julia saves that.

---

<div class="post-metadata">

**Author:** ![pixel27](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pixel27/32/8902_2.png) [@pixel27](https://discourse.julialang.org/u/pixel27)\
**Post date:** [April 22, 2020, 10:21pm UTC](https://discourse.julialang.org/t/open-up-vim-instance-to-write-then-save-the-text-to-a-variable/38047/4 "2020-04-22T22:21:26Z")

</div>

Something like this maybe?

```julia
    path, io = mktemp()
    close(io)
    run(`vim $path`)
    f = read(path, String)
    rm(path)

```

---

<div class="post-metadata">

**Author:** ![tbeason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tbeason/32/15898_2.png) [@tbeason](https://discourse.julialang.org/u/tbeason)\
**Post date:** [April 22, 2020, 10:24pm UTC](https://discourse.julialang.org/t/open-up-vim-instance-to-write-then-save-the-text-to-a-variable/38047/5 "2020-04-22T22:24:53Z")

</div>

So like a vim REPL mode? That could be interesting maybe

---

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [April 22, 2020, 10:45pm UTC](https://discourse.julialang.org/t/open-up-vim-instance-to-write-then-save-the-text-to-a-variable/38047/6 "2020-04-22T22:45:22Z")

</div>

Wonderful! This is exactly what I am looking for.

---

<div class="post-metadata">

**Author:** ![pixel27](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pixel27/32/8902_2.png) [@pixel27](https://discourse.julialang.org/u/pixel27)\
**Post date:** [April 22, 2020, 10:46pm UTC](https://discourse.julialang.org/t/open-up-vim-instance-to-write-then-save-the-text-to-a-variable/38047/7 "2020-04-22T22:46:35Z")

</div>

You could write something to the file before calling `close(io)` the user would see it when vim opens the file…but then you would need to remove it from f when you read the contents of the file.
