Search code examples
codemirrorjupyter-lab

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


Solution

  • 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.