Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I add a ruler (vertical line) to CodeMirror editors in JupyterLab?

I would like to add a ruler at 80 characters. I know that you can add rulers to CodeMirror, but I don't know if I'm supposed to place the corresponding javascript in a file somewhere, or in JupyterLab's Advanced Settings Editor > CodeMirror > User Overides section, or if I should do something else all together to get it working.

I'm using JupyterLab 0.31.8

like image 381
jpobst Avatar asked Mar 16 '18 14:03

jpobst


People also ask

How do you add a ruler to Jupyter notebook?

To add a horizontal ruler line to the code cell in the notebook, select 'Notebook' from the Advanced Settings Listing pane. That should then become blue text with the blue bar to the left in that pane like you showed in your first image, but for 'Notebook' now.

Is JupyterLab a text editor?

Jupyter is now a full-fledged IDE It's a good practice to work like that, so we don't pollute the Notebooks with many definitions. But the text editor bundled with JupyterLab is just that: a simple, featureless text editor.


1 Answers

The feature is available in the recently shipped JupyterLab 1.0.

The feature now is implemented in the current JupyterLab 1.0 alpha (see this PR).

Enable rulers in JupyterLab 1.0

Note: in addition to adding

{
    "codeCellConfig": {
        "rulers": [80]
    }
}

to the Notebook settings as shown above, you can also add

{
    "editorConfig": {
        "rulers": [80]
    }
}

to the Text Editor settings.

like image 75
Michael Gecht Avatar answered Sep 21 '22 18:09

Michael Gecht