External text editor workflow tips

Any people out there using JupyterLab along with an external text editor like Vim or Emacs? If so, care to share any tips on your setup/workflow?

I’d basically like to have a notebook open both in my preferred text editor and in JupyterLab, side by side. I’d use the text editor to edit the contents of the notebook, and JupyterLab to run the code, display the results and interact with them.

I know at the basic level, I can use jupytext to sync a Markdown file with a notebook. Has anyone figured out how to have additional niceties on top of that? E.g.:

  • controlling JupyterLab from the text editor:
    • refreshing the notebook view in JupyterLab
    • running a code cell
    • scrolling to the cell you’re editing
  • completion

Any tips are appreciated, as well as links to threads where this type of functionality is being discussed, if any :slight_smile:

See jupytext intro from PyCon 2020.

Thanks! That’s a good summary of the basics, which I was mostly aware of :slight_smile:

What I had in mind is a workflow like a notebook open in Neovim and JupyterLab side-by-side, with JupyterLab used mainly as just a viewer, but I can control it from Neovim (e.g. to execute or scroll to cells, get completion suggestions from the kernel).

Honestly, I have no idea whether JupyterLab can even be controlled from the outside like this, I was just curious.

This goes the other way around but GitHub - jupyterlab-contrib/jupyterlab-fileopen: A JupyterLab extension that adds a shortcut for opening files using the OS file explorer might be of your interest. There is also a feature request related to this idea in Open definition in an external editor · Issue #684 · jupyter-lsp/jupyterlab-lsp · GitHub. What features of Neovim are you missing in JupyterLab?

Thanks a lot, those look like very interesting links at first click, will explore further!

What features of Neovim are you missing in JupyterLab?

It’s not really about any particular feature that JupyterLab could easily emulate (although Vim keybindings in notebook cells would be nice) – it’s mostly just about muscle memory and being in a familiar environment that I have customized to suit my habits over the years :slight_smile:

Don’t get me wrong, I like JupyterLab a lot, I think it’s an impressive achievement, I use it all the time for teaching and data analyses. It’s just that I’ve done most of my text editing in (Neo)vim for years, so I feel a bit hamstrung anywhere else at times. (Not necessarily because Neovim is better than the other options, but because I’m used to it.)

1 Like