Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable VIM mode for editing notebooks in jupyter-lab?

Tags:

jupyter-lab

I'm new to jupyter lab. In settings -> text editor key map it has a vim option which, when enabled, allows me to edit .py files with vim-style editor. However, this behavior does not carry over to .ipynb files. How can I enable this for all files edited in jupyter-lab (most importantly .ipynb)?

Internet search has revealed a plenty of vim addons for jupyter (mostly jupyter-notebook I believe), but since this behavior is already available out of the box for .py, I would assume this can be somehow configured without third-party addons. In any case, I will be grateful for information because what I find on the Internet seems to be mostly outdated/related to jupyter-notebook.

like image 344
Jatentaki Avatar asked Oct 18 '19 19:10

Jatentaki


People also ask

Is it better to use Vim or Jupyter in the notebook?

That issue notes how there are necessarily going to be conflicts with existing shortcuts in a vim mode. So the choice becomes how to best strike the balance between vim-iness and jupyter-iness of vim mode in the notebook. The unfortunate truth is that the end result will not be a perfect representation of either vim or jupyter.

What is the use of Jupyter Notebook in machine learning?

Jupyter Notebook is widely used most popular tool for machine learning and data science development. Starting with IPython 2.0, the Jupyter Notebook has two modes: command mode. Keyboard will behave differently depending upon which mode you have selected. Green cell border is an indication of whether edit mode is enabled or not.

What is the history of the Vim and Jupyter Notebook extensions?

They update some vim commands to be make sense in the notebook context, maintain the most fundamental vim actions, and update some jupyter commands to be more vim-like. Beyond that they have a long history (and large userbase) dating back to the first commit in 2015 for the vim extension for jupyter notebook.

What are the different modes in Jupyter Notebook?

Jupyter Notebook Modes There are two modes in Jupyter. These are edit mode and command mode. If the cell has a green border, that means you’re in edit mode.


Video Answer


1 Answers

jupyterlab 3.x+:

pip install --upgrade jupyterlab-vim

jupyterlab 2.x:

jupyter labextension install @axlair/jupyterlab_vim

jupyterlab 1.x:

jupyter labextension install jupyterlab_vim

History:

The original extension was: https://github.com/jwkvam/jupyterlab-vim

however it was never updated for jlab2.x so the community shifted to a fork: https://github.com/axelfahy/jupyterlab-vim which has subsequently moved to https://github.com/jupyterlab-contrib/jupyterlab-vim

There is also an effort to vim this into jlab core. See: https://github.com/jupyterlab/jupyterlab/issues/8592

like image 131
Ianhi Avatar answered Sep 20 '22 06:09

Ianhi