Reputation: 550
I use version 1.38 of VSCode in combination with the python extension (ms-python.python) to be able to modify jupyter notebooks inside of VSCode. Is there any option to hide the output of specific cells (e.g. when plotting multiple plots in one cell)?
Upvotes: 24
Views: 27040
Reputation: 11
to hide any of cells (input and output) you can just press on a vertical line, which is shows up when you hover cursor on this cell
Upvotes: 1
Reputation: 161
Add the entire code or the part you need to the keybindings.json file:
{ // To collapse active cell input
"key": "ctrl+[",
"command": "notebook.cell.collapseCellInput",
"when": "notebookCellListFocused && !inputFocus && !notebookCellInputIsCollapsed"
},
{ // To expand active cell input
"key": "ctrl+[",
"command": "notebook.cell.expandCellInput",
"when": "notebookCellInputIsCollapsed && notebookCellListFocused"
},
{ //To collapse active cell output
"key": "ctrl+]",
"command": "notebook.cell.collapseCellOutput",
"when": "notebookCellHasOutputs && notebookCellListFocused && !inputFocus && !notebookCellOutputIsCollapsed"
},
{ // To expand active cell output
"key": "ctrl+]",
"command": "notebook.cell.expandCellOutput",
"when": "notebookCellListFocused && notebookCellOutputIsCollapsed"
},
{ // To collapse all cell inputs
"key": "ctrl+shift+[",
"command": "notebook.cell.collapseAllCellInputs"
},
{ // To expand all cell inputs
"key": "ctrl+shift+alt+[",
"command": "notebook.cell.expandAllCellInputs"
},
{ // To collapse all cell outputs
"key": "ctrl+shift+]",
"command": "notebook.cell.collapseAllCellOutputs"
},
{ // To expand all cell outputs
"key": "ctrl+shift+alt+]",
"command": "notebook.cell.expandAllCellOutputs"
}
Change key combinations as you wish.
Upvotes: 0
Reputation: 1175
Put this as the first line of your cell.
%%capture
#Then the rest of your code in the cell...
The output from that cell won't be printed inside the notebook.
Upvotes: 10
Reputation: 754
Bumped into the same problem today. It seems to be that the shortcuts from jupyter notebook are integrated into the jupyter notebook in visual studio code. If you press "o" on a cell, it will hide the cell output.
Upvotes: 57
Reputation: 41
Seems like there's no option for that at the moment.
The official document here doesn't mention that.
https://code.visualstudio.com/docs/python/jupyter-support
Upvotes: 3