# Vim mode in REPL command line

**URL:** https://discourse.julialang.org/t/vim-mode-in-repl-command-line/9023
**Category:** General Usage
**Tags:** repl
**Created:** [February 12, 2018, 10:08pm UTC](https://discourse.julialang.org/t/vim-mode-in-repl-command-line/9023 "2018-02-12T22:08:57Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![pasha](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pasha/32/3319_2.png) [@pasha](https://discourse.julialang.org/u/pasha)
#### Post date: [February 12, 2018, 10:08pm UTC](https://discourse.julialang.org/t/vim-mode-in-repl-command-line/9023/1 "2018-02-12T22:08:57Z")

</div>

I’m not talking about a julia mode for vim - that exists and is lovely. I’m talking about the command line in the REPL - so that when you can escape partway into a long command you can use vim-flavored actions to change your REPL input. It is massively powerful if you have vim in your veins.

I understand from [this ancient issue](https://github.com/JuliaLang/julia/issues/6774) that Julia gave up GNU Readline long ago, and it was left to an “intrepid” developer to build. I’ve looked a bit at julia/stdlib/REPL to find the hooks and approach to do this, but have to ask:

Is someone already doing this? What is involved in doing this? What will make it challenging? It’s an itch I’d like to scratch, but I’ve got work to do (we all do) as well.

---

<div class="post-metadata">

### Author: ![jbrea](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jbrea/32/3879_2.png) [@jbrea](https://discourse.julialang.org/u/jbrea)
#### Post date: [May 3, 2018, 9:13am UTC](https://discourse.julialang.org/t/vim-mode-in-repl-command-line/9023/2 "2018-05-03T09:13:15Z")

</div>

At some point I was also interested in this feature. But now I am happy with [vim-slime](https://github.com/jpalardy/vim-slime): I write my code in vim and with vim-slime send it to the REPL.

---

<div class="post-metadata">

### Author: ![ExpandingMan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/expandingman/32/866_2.png) [@ExpandingMan](https://discourse.julialang.org/u/ExpandingMan)
#### Post date: [May 3, 2018, 3:06pm UTC](https://discourse.julialang.org/t/vim-mode-in-repl-command-line/9023/3 "2018-05-03T15:06:15Z")

</div>

This isn’t a real solution, but I’ve started using Revise.jl by default especially as we face even longer compile times in 0.7, and I think Revise.jl helps with this sort of thing as well. It makes it possible to spend much more of your time editing your code in vim rather than typing anything into the REPL. I pretty much only ever do simple function calls in the REPL.

---

<div class="post-metadata">

### Author: ![pasha](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pasha/32/3319_2.png) [@pasha](https://discourse.julialang.org/u/pasha)
#### Post date: [May 3, 2018, 3:22pm UTC](https://discourse.julialang.org/t/vim-mode-in-repl-command-line/9023/4 "2018-05-03T15:22:12Z")

</div>

> [@ExpandingMan](#):
>
> I pretty much only ever do simple function calls in the REPL.

Maybe it’ll come down to that for now, or slime-ing longer commands over to the REPL. But in R, my usage pattern can involve REPL commands that are three lines long, mostly strung-up `dplyr` stuff. It’s useful to see what works on the data before committing to code. A VIM mode is really useful to tweak those long lines, plus the “muscle memory” issue.

It ain’t gonna write itself, and sadly there doesn’t seem to be a huge demand for it. I need to clear some other projects out before committing to creating/maintaining a public project.

---

<div class="post-metadata">

### Author: ![ExpandingMan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/expandingman/32/866_2.png) [@ExpandingMan](https://discourse.julialang.org/u/ExpandingMan)
#### Post date: [May 3, 2018, 3:26pm UTC](https://discourse.julialang.org/t/vim-mode-in-repl-command-line/9023/5 "2018-05-03T15:26:27Z")

</div>

Yeah, doing vim work always comes with the obstacle of the awful vim script. [Neovim](https://neovim.io) has been forging ahead quite nicely, however, and I think that by now it is possible to do a lot of things in Python.

---

<div class="post-metadata">

### Author: ![ExpandingMan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/expandingman/32/866_2.png) [@ExpandingMan](https://discourse.julialang.org/u/ExpandingMan)
#### Post date: [May 3, 2018, 3:34pm UTC](https://discourse.julialang.org/t/vim-mode-in-repl-command-line/9023/6 "2018-05-03T15:34:47Z")

</div>

Also, I just found [this](https://github.com/bfredl/Neovim.jl). I wonder if it would be worth resurrecting? Although honestly, this is one of those cases where Python actually seems more appropriate than Julia, since we really are talking about scripting here (fast startup times are very important, in my experience). Obviously Julia integration is important for using the REPL though.

---

<div class="post-metadata">

### Author: ![pasha](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pasha/32/3319_2.png) [@pasha](https://discourse.julialang.org/u/pasha)
#### Post date: [May 3, 2018, 4:59pm UTC](https://discourse.julialang.org/t/vim-mode-in-repl-command-line/9023/7 "2018-05-03T16:59:50Z")

</div>

Hmm, what I have in mind was outside of a vim or nvim. I was thinking of the line editor within the REPL, where keystrokes edit what’s on the `julia>` line. Aiming for something like [bindkey -v](http://zsh.sourceforge.net/Guide/zshguide04.html) in zsh. The issue linked above implies that the plumbing is available in `stdlib/REPL/*` to build an extension so this is possible. The issue above talks about embedding nvim into the line, I think, but that seems like overkill?

---

<div class="post-metadata">

### Author: ![ExpandingMan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/expandingman/32/866_2.png) [@ExpandingMan](https://discourse.julialang.org/u/ExpandingMan)
#### Post date: [May 3, 2018, 5:05pm UTC](https://discourse.julialang.org/t/vim-mode-in-repl-command-line/9023/8 "2018-05-03T17:05:25Z")

</div>

The thing on my wishlist is an “advanced terminal”, but I’ve never even seen anything like that being worked on. What I have in mind is something that behaves as much like gnome-terminal as possible but can support things like plotting and pixel addressable graphics. I would be open to using VSCode or Atom this way, but they are simply still too far away from this paradigm: they are still very frustrating to use and it’s still very difficult to completely eliminate all the GUI elements of them.

I suppose a Linux window manager would be the closest thing to what I’m imagining, but I haven’t taken the time to really dive into one yet.

---

<div class="post-metadata">

### Author: ![pasha](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pasha/32/3319_2.png) [@pasha](https://discourse.julialang.org/u/pasha)
#### Post date: [May 3, 2018, 5:17pm UTC](https://discourse.julialang.org/t/vim-mode-in-repl-command-line/9023/9 "2018-05-03T17:17:57Z")

</div>

What would be in that advanced terminal? I know you’ve seen [UnicodePlots.jl](https://github.com/Evizero/UnicodePlots.jl), which heads in that direction.

I know you don’t mean a CLI helper [like this](https://www.linuxjournal.com/content/gui-your-cli), so I’m not sure what else would go in it. I just want to be able to type wwwlllr7 to change a number to 7 and rerun. Come to think of it, VI mode for discourse would be nice too.

As discussed in another thread, all of this would have to work through a remote SSH, too.

---

<div class="post-metadata">

### Author: ![ExpandingMan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/expandingman/32/866_2.png) [@ExpandingMan](https://discourse.julialang.org/u/ExpandingMan)
#### Post date: [May 3, 2018, 5:23pm UTC](https://discourse.julialang.org/t/vim-mode-in-repl-command-line/9023/10 "2018-05-03T17:23:57Z")

</div>

The idea in my head is all the advantages of an IDE (especially plotting and interactivity when you need them) but none of the other GUI features. In other words, I do really like that in an IDE you can get a pretty plot, maybe with a slider or something and things like table viewers, but I’d want to cut out all of the other GUI baggage that comes with it. In other words, the philosophy would be “No GUI ever, except when it’s _actually_ useful”. Modern IDE’s seem more like their philosophy is “Get in the way of everything, GUI the hell out of the user”. And no the CLI helper was not the sort of thing I meant.

Admittedly this isn’t something I’ve carefully thought through, so maybe it’s a silly idea.

---

<div class="post-metadata">

### Author: ![pasha](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pasha/32/3319_2.png) [@pasha](https://discourse.julialang.org/u/pasha)
#### Post date: [May 3, 2018, 5:38pm UTC](https://discourse.julialang.org/t/vim-mode-in-repl-command-line/9023/11 "2018-05-03T17:38:50Z")

</div>

Gotcha. So far linux and tmux and the i3 tiling window manager do enough of that for me; I know you’re on similar rig. I put plots on a floating window above the tiles. In a way, linux is my IDE.

I like your idea. Another way to frame it would be to have one or more packages of “helper” GUI applications that would launch from the REPL when you needed to see a table, or a code hierarchy, or debugger, much the way that Plots does. Authors could implement one idea at a time that they liked from the IDEs.

---

<div class="post-metadata">

### Author: ![ExpandingMan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/expandingman/32/866_2.png) [@ExpandingMan](https://discourse.julialang.org/u/ExpandingMan)
#### Post date: [May 3, 2018, 5:45pm UTC](https://discourse.julialang.org/t/vim-mode-in-repl-command-line/9023/12 "2018-05-03T17:45:35Z")

</div>

Yeah, I’m using tmux and nvim in Ubuntu. I’ve checked out i3 a little bit but, like I said, I just haven’t invested the time in it yet to see if it’s really something I’m looking for.

Here’s my vision: You boot up your operating system and are dumped into a blank terminal running something akin to tmux. If you want to go to a web page, you type `firefox julialang.org` or if you want to search duckduckgo you do `firefox -d "julia lang"` and embedded in the terminal you will get a piece of a firefox window that you can use in the usual way with tabs and everything, but which you can easily just go back into the terminal from with something like vim modes and commands, and you can also resize it so that you have your browser and terminal side by side. At any time you can open a new tmux tab and switch between them. I envision plots, data viewers and interactive debuggers working in a similar way.

Maybe I’ve just described i3, but it didn’t quite seem like it from what I was seeing.

---

<div class="post-metadata">

### Author: ![pasha](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pasha/32/3319_2.png) [@pasha](https://discourse.julialang.org/u/pasha)
#### Post date: [May 3, 2018, 6:07pm UTC](https://discourse.julialang.org/t/vim-mode-in-repl-command-line/9023/13 "2018-05-03T18:07:52Z")

</div>

Ok - so if you type `firefox julialang.org` in a terminal now, it’ll open that URL in a new tab wherever you have firefox running, or launch a window in a random place.

The only difference with i3 or any tiling wm is that would put the window in a predicable place, and you could resize the tiles with keystrokes. There’s no wasted space, no background image, no mousing around.

I like the idea of julia helper applications - a slick table viewer is the main thing that comes to mind. Not sure if I’d even use that. The GUI builders seen on IDEs come to mind as well, but not for Julia or numeric/backend programming.

I think emacs or vim would do everything else. Looking at [RStudio](https://www.rstudio.com/products/rstudio/features/), I also see a help file viewer, workspace viewer, git, package manager, lots of things that are a single cli command.

---

<div class="post-metadata">

### Author: ![ExpandingMan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/expandingman/32/866_2.png) [@ExpandingMan](https://discourse.julialang.org/u/ExpandingMan)
#### Post date: [May 3, 2018, 6:30pm UTC](https://discourse.julialang.org/t/vim-mode-in-repl-command-line/9023/14 "2018-05-03T18:30:34Z")

</div>

Yeah, the current situation is not terrible, which is probably why it’s been status quo forever now.

Sounds like I should put in the time to try out i3 at some point.

Think I’ll wind up using [sway](http://swaywm.org) as I am looking forward to the future with Wayland 😄

---

<div class="post-metadata">

### Author: ![jw3126](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jw3126/32/3086_2.png) [@jw3126](https://discourse.julialang.org/u/jw3126)
#### Post date: [May 3, 2018, 7:34pm UTC](https://discourse.julialang.org/t/vim-mode-in-repl-command-line/9023/15 "2018-05-03T19:34:20Z")

</div>

Depending on the use case, jupyter notebook is a nice option for interactivity + vim mode.

---

<div class="post-metadata">

### Author: ![pasha](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pasha/32/3319_2.png) [@pasha](https://discourse.julialang.org/u/pasha)
#### Post date: [May 3, 2018, 9:06pm UTC](https://discourse.julialang.org/t/vim-mode-in-repl-command-line/9023/16 "2018-05-03T21:06:02Z")

</div>

Oh, look at that, there’s a [vim mode for jupyter](https://github.com/lambdalisue/jupyter-vim-binding).

---

<div class="post-metadata">

### Author: ![chakravala](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chakravala/32/6832_2.png) [@chakravala](https://discourse.julialang.org/u/chakravala)
#### Post date: [May 3, 2018, 10:11pm UTC](https://discourse.julialang.org/t/vim-mode-in-repl-command-line/9023/17 "2018-05-03T22:11:54Z")

</div>

> [@pasha](#):
>
> Gotcha. So far linux and tmux and the i3 tiling window manager do enough of that for me; I know you’re on similar rig. I put plots on a floating window above the tiles. In a way, linux is my IDE.

A while back I created an unregistered package that uses vim for text editing in the REPL, specifically, it’s meant for `LaTeX` editing for `i3` users. [https://github.com/chakravala/JuliaTeX.jl](https://github.com/chakravala/JuliaTeX.jl)

Eventually I plan to explain more details what it’s for, but right now it’s still a “secret”.

But essentially, this is part of an interface that will allow LaTeX editing with vim in the Julia REPL, more generally, there will be an associative database for organizing references and dependences of mathematical defintions and theorems and LaTeX parsing too.

Vim just happens to be a way of interfacing with it in the Julia REPL. Basically, you can just write your text buffer into a temporary file in the OS and then launch vim for the editing, and Julia can launch a PDF viewer automatically to help with the display of it. Not ready for use yet, it will be announced when ready.

This is going to provide a completely new workflow for editing LaTeX files in Julia with vim, but not ready yet.

> [@ExpandingMan](#):
>
> Sounds like I should put in the time to try out i3 at some point.
> 
> Think I’ll wind up using sway as I am looking forward to the future with Wayland 😄

Try it! it’s not as difficult as it looks, it’s very easy. Even got my dad to use it.

Also, `sway` is really easy to have on your system if you have i3. I have both installed, and can switch.

---

<div class="post-metadata">

### Author: ![stephancb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stephancb/32/14243_2.png) [@stephancb](https://discourse.julialang.org/u/stephancb)
#### Post date: [May 4, 2018, 6:55am UTC](https://discourse.julialang.org/t/vim-mode-in-repl-command-line/9023/18 "2018-05-04T06:55:23Z")

</div>

Slightly off-topic, but how about integrating, perhaps optionally

[https://github.com/junegunn/fzf](https://github.com/junegunn/fzf)

into the Julia REPL? As far as I can see, for this one would need to dig into julia/stdlib/REPL?

---

<div class="post-metadata">

### Author: ![ExpandingMan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/expandingman/32/866_2.png) [@ExpandingMan](https://discourse.julialang.org/u/ExpandingMan)
#### Post date: [May 4, 2018, 1:36pm UTC](https://discourse.julialang.org/t/vim-mode-in-repl-command-line/9023/19 "2018-05-04T13:36:08Z")

</div>

I was looking into it more yesterday and this is indeed what I’m going to do! It does look like sway or i3 will allow me to do much of what I’ve been imagining, I’m pretty excited.

So far I haven’t been able to actually run sway (except in a window in GNOME), I keep getting “Can’t open wayland socket” (at least one 1 of the machines I tried it on I was already running Wayland GNOME so I knew Wayland was set up properly). The github documentation for Sway hasn’t been too helpful yet, if you can point me to any set up guides I would be hugely appreciative.

---

<div class="post-metadata">

### Author: ![chakravala](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chakravala/32/6832_2.png) [@chakravala](https://discourse.julialang.org/u/chakravala)
#### Post date: [May 4, 2018, 1:41pm UTC](https://discourse.julialang.org/t/vim-mode-in-repl-command-line/9023/20 "2018-05-04T13:41:52Z")

</div>

What OS are you using? The Arch Wiki has some information [Sway - ArchWiki](https://wiki.archlinux.org/index.php/Sway)

> Sway doesn’t work well (or at all) under VirtualBox.

Have you previously installed and used i3 before? If so, you can just copy your config folder. Otherwise, you can use the defaults provided by sway. It’s easy to install if you use the Arch Linux package manager.

Not sure about GNOME with Wayland, but for sway just type `sway` into your TTY instead of `startx` to launch.

[Next page](https://discourse.julialang.org/t/vim-mode-in-repl-command-line/9023.md?page=2)
