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:
Next, click on JSON Settings Editor
in the top right-hand corner:
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:
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:
About the author
I'm currently working on short form content at ClickHouse. I publish short 5 minute videos showing how to solve data problems on YouTube @LearnDataWithMark. I previously worked on graph analytics at Neo4j, where I also co-authored the O'Reilly Graph Algorithms Book with Amy Hodler.