gold plated accessories

Wow Vivaldi and JupyterLab Vim are cool

0

OK, spent the day making JupyterLab really work for me. Key to this has been keyboard shortcuts. They are so different on Colab, Deepnote and even between JupyterLab and Jupyter Notebook. But there is hope with two cool finds:

Vivaldi is a Chromium based browser, so it can accept Chrome Store extensions but it is completely private. So it is kind of the best of both words. I’m typing on it now and other than having to set up Vivaldi sync instead of Google Sync of actions, Its a wonder I had not found it earlier.

Then as I’ve switched from Deepnote to my roll my own JupyterLab environment so I can use things like JupyterLab-vim I’ve discovered a whole new set of short cuts and things. Here are some of the most valuable for folks trying to make a JupyterLab notebook a way to present data:

You can now fold code so that you don’t have to display the code and just get the output. They already do this for Markdown, so when you close a text window, you just get the output Markdown and for most code, you want to do the same. You can set this with a simple typing and for Vi nerds, these are same folding commands that it has:

  • ZM which hides all code
  • ZC if you just want to hide a specific cell so you can have charting stuff appear as just charts,
  • ZO but you can leave real code open with ZO when on a specific cell or
  • ZR to expand all code.

Add you can use VI shortcuts and things really easily. If you want to try it checkout https://docker.com/tongfamily/jupyterlab where I’ve stuck an image that does this.

The one remaining nagging problem is word wrapping, it doesn’t seem to work. Sigh, always something. So in studying this, for code line wrap, you can go to Settings > Advanced Setting Notebook and add to the User Preferences

"{codeCellConfig: { "lineWrap": true }}

Then for text, I’m not sure how this interacts with the super awesome vim bindings, but you go to Settings > Advanced Settings > Text Editor and then in the User Preferences, you can add which says instead of wrapping and the size of the windows you are editing in, it looks for the wordWrapColumn and breaks it there.

{"editorConfig": {"lineWrap": "wordWrapColumn", "wordWrapColumn": 80, }}

Installing the rest of an IDE

Well, the big change with JupyterLab is that the extensions are way more robust, so here is the collection I’ve been using to try to make it work as vim does with code formatting, etc. The nice thing is that you pip to install these and then JupyterLab automagically picks them up. You can see all the available commands with ⌘-⌃-C and you can see all the assigned shortcuts too.

  • Jupyterlab_vim. Add vim bindings like gg to go to the top of the document and editing that works like vim.
  • Jupyterlab_git. I haven’t quite gotten this working yet, but basically, you should be able to check in and check out a repo that has the notebooks in them. The reported fix is that it doesn’t recognize you are in the repo so you need an explicit jupyter server extension enable --py jupyterlab_git
  • Jupyterlab_github. Browse github repos and look at notebooks there.
  • Jupyter_code_formatter. This lets you use Python tools like Black to format things and make your code look nice. You can’t run this automatically, so you need to assign a keyboard shortcut to it which is yet more Jason in the Settings > Advanced Settings > Keyboard Shortcuts
  • Jupyter DEbugger. This requires the new Xeus-Python but you get single-stepping, variables and all the rest
  • Jupyterlab-hdf5. Look at HDF5 files and see what data is there.

Related Posts

This site uses Akismet to reduce spam. Learn how your comment data is processed.