Jupyter Notebook Shortcuts

2 min read

Get 10-day Free Algo Trading Course

Last Updated on July 16, 2022

Notebooks are tools that allow us to use markdown along with our code, to improve readability and really add to that storytelling aspect of a project. JuPyteR — short for Julia,Python and R — is probably the most popular notebook used and comes as part of the standard anaconda installation process.

When you click on the Help tab of Jupyter’s taskbar you’ll see a list of references, the user interface tour and much more. Included in this would be the Keyboard Shortcuts menu which lets you view all of the possible ways to quickly execute common track-pad tasks using your keyboard. Today we’ll be talking about the most useful of these options.

The Keyboard Shortcuts menu is divided into 2 categories called Command Mode and Edit Mode. We will be keeping this structure as we move on to the main event in our article.

Before we begin it is important for Mac users to keep the following conversion in mind:

Ctrl — command key

Shift — ⇧ Shift

Alt —  option

Edit Mode

To enter the edit mode, press the Enter key. These shortcuts may seem very familiar to the ones you may use in other text editors and general computer use.

Ctrl-S: Save and Checkpoint 

Tab: code completion or indent

Indenting Selected Text

Ctrl-]: indent Ctrl-[: indent to the left (dedent)

More Text Editing

Ctrl-A: select all Ctrl-Z: undo

Ctrl-/: comment Ctrl-D: delete whole line

Ctrl-U: undo selection Insert: toggle overwrite flag

Go To

Ctrl-Home: go to cell start Ctrl-Up: go to cell start Ctrl-End: go to cell end

Ctrl-Down: go to cell end Ctrl-Left: go one word left 

Ctrl-Right: go one word right 

Delete / Redo

Ctrl-Backspace: delete word before Ctrl-Delete: delete word after

 Ctrl-Y: redo Alt-U: redo selection 

Run

Shift-Enter: run cell, select below Ctrl-Enter: run selected cells

Alt-Enter: run cell and insert below

Split

Ctrl-Shift-Minus: split cell at cursor

Command Mode 

To enter the command mode, press the Esc key.

Enter: enter edit mode F: find and replace 

Insert Cells

A: insert cell above B: insert cell below

Run and Insert Cells

Shift-Enter: run cell, select below Alt-Enter: run cell and insert below 

Change Cell Type

Y: change cell to code M: change cell to markdown R: change cell to raw

Change Markdown Header Size — Up to 6 sizes with 1 being the Largest

1: change cell to heading size 1 2: change cell to heading size 2 

Select Multiple Cells

Shift-Up: extend selected cells above Shift-Down: extend selected cells below

Cut, Copy and Paste

X: cut selected cells C: copy selected cells

Shift-V: paste cells above V: paste cells below

Merge Cells

Shift-M: merge selected cells, or current cell with cell below if only one cell is selected

Z: undo cell deletion O: toggle output of selected cells

The keystrokes for the following are misleading. We have listed them as they are in the keyboard shortcut menu, however it is important for you to remember that the actual process does NOT include the comma. So for deleting selected cells you would actually type DD .

D,D: delete selected cells I,I: interrupt the kernel 0,0: restart the kernel 

Miscellaneous

H: show keyboard shortcuts Q: close the pager

Shift-L: toggles line numbers in all cells, and persist the setting

Shift-Space: scroll notebook up Space: scroll notebook down

Aside

The command palette runs any command by name. To open the command palette, use Esc to enter command mode and then press P .

Conclusion

Shortcuts can prove quite useful in helping you to maintain focus by avoiding some extra scrolling with your mouse. In fact Brainscape claims that just by using keyboard shortcuts alone, you can increase your overall productivity by 3.3%, saving yourself a total of 64 wasted hours in a year. Whether you believe this or not, at the very least using shortcuts definitely helps you cut-down on using that annoying track pad, while making you look super cool at the same time.

I kid, but until next time, do enjoy the shortcuts that you’ve learned today!

Jovan Medford

Leave a Reply

Your email address will not be published. Required fields are marked *