Jupyter Notebook
Some handy jupyter lab shortcuts for better notebook work in ML from this tutorial here.
Command & Edit Modes
There are two distinct modes in jupyter notebooks. Different shortcuts apply based on which mode you are in (think vim modes). When your cursor is active inside a cell, you are in edit mode. You can also enter edit mode with ENTER or clicking on the cell editor area. If you escape with ESC then you are in command mode.
Command mode gives you control over the notebook as a whole, while edit mode is specific to the cell that you are editing.
Use command mode for notebook and cell actions and edit mode to type in individual cells.
Running Cells
To run cell in either mode:
CTRL+ENTERruns cellSHIFT+ENTERruns and moves to cell below
Command Mode Shortcuts
The basic overview:
- Navigation:
ENTER,up/k,down/j - Saving:
s - Change cell types:
y,m - Cell creation:
a,b - Cell editing:
x,c,v,z
Useful shortcuts I would use often:
- Go up and down cells with
jandklike vim - Create cells above current cell with
aand below current cell withb - Change the cell type to markdown with
mor code withy
Cell level operations:
- Cut cells with
x(good for delete as well) - Copy cells with
c - Paste cells with
v - Undo cell operation with
z
You can also merge cells:
- Select multiple cells with
SHIFT+upandSHIFT+down - Merge cells with
SHIFT+m - On single cell
CTRL+SHIFT+mto merge with the one below
You can string these shortcuts together. An example is selecting multiple cells with SHIFT+up or SHIFT+down and converting all of them to markdown with m.
Sometimes output of cells can long and clutter the screen:
- Collapse and uncollapse output of a cell using
o
Edit Mode Shortcuts
Ones I commonly use:
- Toggle between comment and uncommented code with
Ctrl+/. - Split cells with
CTRL+SHIFT+-at the cursor inside a cell.