Let's suppose I am editing a code in a particular cell of a jupyter notebook in VSCode. Then I search for something and it takes me to another cell somewhere on the notebook. How can I navigate back to the original cell without tediously searching for it with a slider? Any appropriate keys to do that?
I'm looking for a way to put a jupyter notebook cell in VSCode in interactive mode so that it runs the cell when its contents change without having to run it explicitly.
If there's no existing solution, is it somehow possible to automate executing the cell periodically or does the VSCode jupyter lab integration offer some scripting hooks?
Alternatively, is there a possibility to explicitly execute a cell without loosing the cell focus and its current cursor position? CTRL+Enter directly doesn't work; the tabulator key needs to be pressed four times additionally to get back to the cell.
My default Jupyter Notebook toolbar in VS Code has a command "Clear Outputs of All Cells". I would like to add a similar but different command Notebook: Clear Cell Outputs, which only clears one cell at a time. I can do that by pressing ALT + DEL, but it would be convenient to have it in toolbar.
I have added this button to the Context Menu Extra extension (v0.4.0) (You need VSC v1.62, because I don't know when some experimental API got public)
If the cell has output you should see the "Clear Cell Output" button in the cell toolbar at first position.
There is no documentation of the allowed groups for this menu. I have used a group the Jupyter extensions also uses. That is the reason it is one of the first buttons.
Is there a way to enable smooth scrolling in vscode notebooks?
I'd like to use the up/down arrows to scroll through the notebook and not have it shift focus from cell to cell.
In Jupyter notebooks (webserver), it can be done by inserting the following code in the first cell:
%%javascript
Jupyter.keyboard_manager.command_shortcuts.remove_shortcut('up');
Jupyter.keyboard_manager.command_shortcuts.remove_shortcut('down');
Unfortunately, the same command does not work in vscode.
How do I enable it?
How do I enable vertical scrolling in a code block in a jupyter notebook?
I've done it accidentally before, but now I can't reproduce it. What I found was set autoscroll = true in the file itself using a text editor...
However, I did that... and it already has a setting, "scrolled": true. In the notebook, it has only horizontal scrolling, so I guess that is what the "scrolled" setting modified.
In order to enable vertical scrolling in an output cell of the notebook, you just need to click to the left of the cell content (in the margin, you will see the area becomes slighty shaded when you are over it).
If you double click, the content of output cell will be hidden.
If you would like to hide the content of an input cell, see also Scroll windows for code in iPython (Jupyter) Notebooks?.
As suggested by #Mandy, to turn on horizontal scrolling in Jupyter code window just go to Cell>Current/All Outputs>Toggle Scrolling
You can try Cell -> Current Outputs -> Toggle Scrolling in the Jupyter UI to enable the scrolling for the output of one cell.
Run this code at the end of yours:
from IPython.display import display, HTML
js = "<script>$('.output_scroll').removeClass('output_scroll')</script>"
display(HTML(js))