How to get Vim editor extension working?

Hi!

I’m new to Jupyter (just started the fast.ai course), and I’ve set up an environment to run on my local machine. I want to set up vim mode (using GitHub - jupyterlab-contrib/jupyterlab-vim: Vim notebook cell bindings for JupyterLab), but I can’t get it to work, and I’m feeling very stupid right now. Reading the documentation, it sounds like it should “just work”, but it doesn’t, and I don’t even know where to look to dig deeper. A summary of where I am/what I’ve tried:

  • I’m running Python 3.11.3 on MacOS 13.4.1, installed via Homebrew
  • I’m running JupyterLab 3.6.3, installed via pip
  • I’ve installed the jupyterlab-contrib version of the vim plugin, i.e. pip install jupyterlab-vim
  • I’ve restarted JupyterLab

At this point, given the very terse instructions in the plugin README, I expected things to “just work”, since it doesn’t say to do anything more than just install the pip package. However, there is no Vim editor mode enabled, so I’ve tried a few more things:

  • I’ve read the JupyterLab extensions documentation (although I’ve probably missed something). (I’m not allowed to include the link, since Discourse says I’m a n00b).
  • I’ve run jupyter lab build
  • I’ve selected vim from the “Settings->Text editor key map” menu
  • I’ve enabled extensions in the leftmost toolbar in JupyterLab
  • I’ve searched for “vim” in the extensions panel and found a few results:
    • axlair/jupyterlab_vim (with an at sign before, but I’m not allowed to use that since Discourse thinks I’m mentioning a user, and I’m a n00b)
    • jupyterlab_vim
    • amosbird/jupyterlab_vim
    • ryantam626/jupyterlab_vim
    • jupyterlab_vim-system-clipboard-support
  • I tried to install the version with no prefix (i.e. simply jupyterlab_vim) from the extensions panel, but this seems to point to the old/original version of the plugin at GitHub - jwkvam/jupyterlab-vim: Vim notebook cell bindings for JupyterLab, which is abandoned and only supports JupyterLab 1. I get a version mismatch error when I try to install it.
  • I haven’t tried any of the forked versions, since I want to run the “official” (?) version from jupyterlab-contrib, and it doesn’t show up in the list.

Can anyone tell me what I’m doing wrong/missing? It seems like I have a fundamental misunderstanding about how extensions work, but I can’t for the life of me figure out what the problem is.

Thanks,

Mats

pip install jupyterlab-vim should just work indeed. You definitely should not need to run jupyter lab build as a user (ever). I personally do not use the extensions panel on 3.x as it uses the old extension system which is problematic, but it is greatly improved in 4.0.

  • Can you paste the result of jupyter labextension list?
  • When you got to “Settings Editor” in JupyterLab do you see a vim section there?

Thanks for the reply. Sounds like there’s some fundamental problem with my Jupyter installation (or the underlying Python), so maybe I should just start over. At least it’s good to know that it’s supposed to work the way I thought.

This is the output from jupyter labextension list:

JupyterLab v3.6.3
Other labextensions (built into JupyterLab)
app dir: /opt/homebrew/Cellar/python@3.11/3.11.3/Frameworks/Python.framework/Versions/3.11/share/jupyter/lab
@jupyter-widgets/jupyterlab-manager v5.0.7 enabled OK

In the “Advanced settings editor”, there is a section called “Notebook Vim”, with the “Enabled” checkbox checked (and nothing else). However, it’s still there if I pip uninstall jupyterlab-vim, so I don’t know if it’s related.

I’m think going to install pyenv, set up a clean Python version just for Jupyter, install everything again, and see what happens. I’ll report back.

Thanks again,

Mats

Hello again,

Sorry for the delay - this is not my day job, so things happen mostly on weekends. I have solved the problem, and I think I know the proximate cause, namely that Jupyter-lab ran with the wrong application path. This is the output from jupyter lab path:

Application directory: /Users/mats/.pyenv/versions/3.11.3/envs/jupyter/share/jupyter/lab
User Settings directory: /Users/mats/.jupyter/lab/user-settings
Workspaces directory: /Users/mats/.jupyter/lab/workspaces

But when I ran jupyter-lab --no-browser, I got the following (timestamps removed). Note that the application directory is different to the above.

Package jupyterlab took 0.0000s to import
jupyterlab | extension was successfully linked.
JupyterLab extension loaded from /opt/homebrew/lib/python3.11/site-packages/jupyterlab
JupyterLab application directory is /opt/homebrew/Cellar/python@3.11/3.11.3/Frameworks/Python.framework/Versions/3.11/share/jupyter/lab
jupyterlab | extension was successfully loaded.

I can’t figure out why it was using that particular Python environment - I’m now using pyenv and virtualenv, and the output from jupyter lab path above indicates those should be working. But when I ran pip3 uninstall jupyterlab in the /opt/homebrew/Cellar... installation, JupyterLab switched over to using the correct app directory, and now the vim plugin works immediately after running pip install jupyterlab-vim.

/ Mats

1 Like

I have similar problem.
I’ve installed jupyterlab 4.0.1 and jupyterlab-vim 0.16 under ~/.local/lib/python3.11/site-packages/. I didn’t use virtualenv.

When I started jupyter-lab, I could confirm that axlair-jupyterlab-vim was installed and enabled in extension manager. However I din’t see Text Editor Key Map or other vim keybinding settings.

The jupyterlab-vim extension (version 0.16) works with jupyterlab 3.6.5, but not jupyterlab 4. I suggest that you pin the version that works with one of the lines of shell code below and submit an issue at Issues · jupyterlab-contrib/jupyterlab-vim · GitHub.

pip install jupyterlab==3.6.5
conda install -yc conda-forge jupyterlab==3.6.5
mamba install -yc conda-forge jupyterlab==3.6.5