How to enable code folding in Jupyter Lab

Question:

Running JupyterLab version 3.0.0 and would like to enable code folding (collapse classes, functions etc in Python). I have followed the instructions in this Jupyter Lab github post:

Under Settings / Text Editor, I have these User preferences (right pane):

{
    "editorConfig": {
        "lineNumbers": true,
        "codeFolding": true
    }
}

And I do not see any triangles appearing on the left side of the cells. What else do I need to do in order to enable code folding?

For abundance of clarity, this question pertains to JupyterLab specifically.

Asked By: CarlosE

||

Answers:

Those instructions are specifically for the text editor, not the notebook interface.

Try this instead, in Settings / Notebook:

{
    "codeCellConfig": {
        "codeFolding": true
    }
}

If you want to enable code folding for Markdown or raw cells, see markdownCellConfig and rawCellConfig respectively.

Answered By: Chris

In addition to Chris’ answer, I enabled code folding in Lab by going to menu:

Settings -> Advanced Settings Editor -> Cell Toolbar -> Notebook -> Rulers -> Checked box for "CodeFolding".

I’m using Labs 3.5.0.

Answered By: Eric Kreipe
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.