Prab-mat
Prab-mat

Reputation: 65

How to get indentation lines in Jupyter Lab/Jupyter Notebook?

enter image description here

How can I add Indentation lines like what is shown above in Jupyter Lab/Notebook?

I have tried a lot and went into the settings (not much as I am a beginner and I don't know most of the stuff) but in Jupyter I can only get code numbers from the View button but not these beautiful lines which help a lot when doing the indentation.

Upvotes: 6

Views: 8289

Answers (2)

pfabri
pfabri

Reputation: 1106

2024 Update

This has recently become possible through the fresh jupyterlab-indent-guides plugin by user firai on GitHub.

It works well: enter image description here

You can install it via the extension manager in JupyterLab or through pip:

pip install jupyterlab-indent-guides

If you're on Windows an encounter permission errors whilst using JupyterLab's extension manager this post might help you: Win10 Jupyter Lab Extension Installation Throws Permission Error [Errno 13]

Upvotes: 3

krassowski
krassowski

Reputation: 15379

The default editor used by Jupyter Notebook and JupyterLab (CodeMirror) does not support indentation markers as for today; it is possible to extend it with an add-on but it seems that there isn't one yet (see Indentation Markers with CodeMirror). I imagine that you would need to create a custom overlay mode to make it work, and it might be in scope for jupyterlab-lsp extension if you would like to suggest this via issue on GitHub.

JupyterLab also allows to use a different editor via extension (and there was a proof-of-concept for that) but I don't think that anyone volunteered to maintain any other editor integration recently.

In the near future JupyterLab will likely migrate CodeMirror 6, and depending on availability of such feature in it it will either have a support for it or not. Or maybe someone will contribute a support for it to an extension. It might turn out to be easier to implement in CM6.

Upvotes: 2

Related Questions