Vim plugin for Jupyter notebooks?

Is it possible to make a VIM plugin to view and edit Jupyter notebooks?

When somebody sends me a Jupyter notebook, I always dread opening up my browser to view it. A much simpler solution would be to just open it from VIM without launching a browser. Instead of displaying the graphics inside the VIM editors, a separate window could be opened to display the results of a graphics calculation, just like in the REPL. Text results would be displayed in VIM.

This is something I don’t have the knowledge, skills, or time for, but maybe someone else might.

3 Likes

If you’re willing to give emacs with evil for vi-emulation a chance, emacs-ipython-notebook is an alternative frontend to jupyter notebooks (originally by the Julia community’s own tkf). I haven’t used it in a year or so, and when I did the support for languages other than python was buggy at best, but it looks like significant development has gone into making it more general since then.

2 Likes

middle ground: use vim in jupyter https://github.com/lambdalisue/jupyter-vim-binding

2 Likes

The following does (something like) what you describe using jupytext, which allows 2-way conversion between ipynb and other formats:

https://github.com/goerz/jupytext.vim

4 Likes

One possibility is to use https://github.com/wmvanvliet/jupyter-vim.
You would have to convert the notebooks with

jupyter-nbconvert -to script Notebook.ipynb

Then you can open a jupyter-qtconsole with

jupyter-qtconsole --kernel=julia-1.2

open the converted Notebook and connect to the qt console in vim with

:JupyterConnect

You can then run a cell, delimited by lines starting with ##, with <localleader> X.
Unfortunately converting the notebook with --to script doesn’t conserver the cell delimiters like the --to python option does for python.

The jupyter-vim plugin does not provide a lot of keybindings for the jupyter-workflow (run and jump to next cell, delete cell, jump to next/previous cell) but these should be not to difficult to come up with.

Edit:
After reading ihnortons answer I found converting the notebook with jupytext:

jupytext --to .jl:percent notebook.ipynb

Will leave the cell structure intact, so it can easily be used with jupyer-vim.

1 Like

More of a trojan horse! :grin:

1 Like

Using VSCode with the Vim extension works if the latest insiders build of both VSCode and the Python extension are used. It works very well.

EIN (Emacs) is buggy for me; E.g., the last line of a cell can often not be deleted with dd.

1 Like

Might not be what people are looking for, but codi.vim is a nice alternative.

There is a new plugin for Neovim that people may be interested. It uses Selenium browser automation to fully synchronise vim to Jupyter Notebook. It will automatically open a Jupyter Notebook server and Firefox so you can view and edit ipynb directly from vim.

https://github.com/kiyoon/jupynium.nvim

1 Like