· jupyterlab til

JupyterLab 4.0.5: Scroll output with keyboard shortcut

In the latest version of Jupyter Notebook/Lab (at least), the output of each cell is shown in full, regardless of how long it is. I wanted to limit the height of the output and then scroll through it within that inner window, ideally by triggering a keyboard shortcut.

I learnt how to do this with the help of Stack Overflow. First, you need to open the settings editor by typing Cmd + , on a Mac or by clicking on that screen from the top menu:

settings editor
Figure 1. Settings > Settings Editor

Next, click on JSON Settings Editor in the top right-hand corner:

json settings editor
Figure 2. JSON Settings Editor

And then paste the following JSON into the shortcuts array:

        {
            "command": "notebook:enable-output-scrolling",
            "keys": [
                "S"
            ],
            "selector": ".jp-Notebook:focus",
            "args": {}
        },
        {
            "command": "notebook:disable-output-scrolling",
            "keys": [
                "Alt S"
            ],
            "selector": ".jp-Notebook:focus",
            "args": {}
        },

This is how it should look like once you’ve done that:

json edited
Figure 3. Keyboard shortcuts added

You can then add a scrollbar to an output cell by pressing s or remove the scrollbar by pressing Alt + s. Below is an example of what happens when you toggle output scrolling:

scrollbar noscrollbar
Figure 4. No scrollbar vs Scrollbar
  • LinkedIn
  • Tumblr
  • Reddit
  • Google+
  • Pinterest
  • Pocket