Shortcuts are one of the best things about Jupyter Notebooks. When you want to run any code block, all you need to do is press Ctrl+Enter. There are a lot more keyboard shortcuts that Jupyter notebooks offer that save us a bunch of time. Below are a few shortcuts we hand picked that will be of immense use to you, when starting out. I highly recommend trying these out as you read them one by one. You won’t know how you lived without them!
A Jupyter Notebook offers two different keyboard input modes – Command and Edit. Command mode binds the keyboard to notebook level commands and is indicated by a grey cell border with a blue left margin. Edit mode allows you to type text (or code) into the active cell and is indicated by a green cell border.
Jump between command and edit mode using Esc and Enter, respectively. Try it out right now! Once you are in command mode (that is, you don’t have an active cell), you can try out the below shortcuts:
- A will insert a new cell above the active cell,
- B will insert one below the active cell
- To delete a cell, press D twice in succession
- To undo a deleted cell, press Z
- Y turns the currently active cell into a code cell
- Hold down Shift + the up or down arrow key to select multiple cells.
- While in multiple selection mode, pressing Shift + M will merge your selection
- F will pop up the ‘Find and Replace’ menu
When in edit mode (press Enter when in command mode to get into Edit mode), you will find the below shortcuts handy:
- Ctrl + Home to go the start of the cell
- Ctrl + S will save your progress
- Ctrl + Enter will run your entire cell block
- Alt + Enter will not only run your cell block, it also adds a new cell below
- Ctrl + Shift + F opens the command palette
- To see the entire list of keyboard shortcuts, press ‘H’ in command mode or go to Help > Keyboard shortcuts. Keep checking this regularly as new shortcuts are added frequently.
That's all for now!
No comments:
Post a Comment