Jupyter notebook is a flexible, open-source web application that helps you create and share readable analyses and documents, which contain images, live codes, comments, equations, formulae, narrative texts, visualizations, and plots together. In other words, the Jupyter notebook contains both code (for instance, Python) and rich text elements (such as equations, paragraphs, etc). You can use it for machine learning, numerical simulation, data cleaning and transformation, data visualization, statistical modeling, and a lot more. If you want to write code a lot faster and in an easier way, you just can’t ignore the benefits of Jupyter Notebook shortcuts. This can be especially helpful if you’re using Jupyter Notebook for Python.
Some important Jupyter Notebook shortcuts
Before talking about the shortcuts, you need to remember a key thing:
Jupyter has two modes, namely
- Edit mode, where you can type text, code, etc. into a cell, and the cell border would have a green color.
- Command mode, which binds the keyboard to actions at the notebook level and lets you move from cell to cell with the selected cell having a blue left margin.
If you’re in the edit mode, you can press esc to move to the command mode. From the command mode, you’ll need to press enter to move to the edit mode on the cell that you have selected.
Given below are some Jupyter Notebook shortcuts that would make your job easier and help save precious time.
- For navigation
Ctrl + up arrow or Ctrl + Home– to go to cell start
Ctrl + down arrow or Ctrl + End – to go to cell end
Ctrl + left arrow – to go to the start of the present or previous word
Ctrl + right arrow – to go to the end of present or next word
- For formatting
Ctrl + a – to select all
Ctrl + / – to toggle comment of present (or selected) line(s)
Ctrl + ] – to indent present (or selected) line(s)
Ctrl + [ – to unindent present (or selected) line(s)
Ctrl + z – to undo your last action
Ctrl + y or Ctrl + shift + z – to redo your last action
- For miscellaneous actions
Option + scrolling click – to do column editing
Tab – to conclude code or indent
Ctrl + shift + – – to split cell
Shift + tab – for tooltip
H – to show all the shortcuts
A – to insert a new cell above the present cell
B – to insert a new cell below the present cell
M – to change the present cell to Markdown mode (which is good for documentation)
Y – to change the present cell back to code
C – to copy cell
V – to paste cell
D + D (you’ll have to press the key twice) – to delete the present cell
Shift + up – to extend chosen cells above
Shift + down – to extend chosen cells below
Ctrl + enter – to run the chosen cell
Alt + enter or Shift + enter – to run the present cell, select below
Esc + i i – to interrupt kernel
Esc + 0 0 – to restart kernel
Shift + M – to merge chosen cells, or the present cell with the cell below in case only one cell is selected
P – to open the command palette
You can use all these Jupyter Notebook shortcuts in your daily work. You can also visit the menu bar’s Help > Edit Keyboard Shortcuts link to edit the existing shortcuts or add more shortcuts.
. . .
To learn more about data science, click here and read our another article.