Skip to content

Instantly share code, notes, and snippets.

@pizofreude
Created March 5, 2025 11:28
Show Gist options
  • Save pizofreude/47740403532da9c7e61fdd152ef52d87 to your computer and use it in GitHub Desktop.
Save pizofreude/47740403532da9c7e61fdd152ef52d87 to your computer and use it in GitHub Desktop.
Jupyter Notebook Keyboard Shortcuts for Windows and Linux

Jupyter Notebook Keyboard Shortcuts for Windows and Linux

General Shortcuts

  • Enter: Enter edit mode
  • Esc: Enter command mode
  • Shift + Enter: Run cell, select below
  • Ctrl + Enter: Run cell
  • Alt + Enter: Run cell, insert below
  • Ctrl + S: Save and checkpoint

Command Mode Shortcuts (press Esc to enable)

  • Up: Select cell above
  • Down: Select cell below
  • A: Insert cell above
  • B: Insert cell below
  • X: Cut selected cell
  • C: Copy selected cell
  • Shift + V: Paste cell above
  • V: Paste cell below
  • Z: Undo cell deletion
  • D, D: Delete selected cell
  • Shift + M: Merge selected cells
  • Y: Change cell to code
  • M: Change cell to markdown
  • R: Change cell to raw
  • 1: Change cell to heading 1
  • 2: Change cell to heading 2
  • 3: Change cell to heading 3
  • 4: Change cell to heading 4
  • 5: Change cell to heading 5
  • 6: Change cell to heading 6
  • 0, 0: Restart the kernel (with dialog)
  • I, I: Interrupt the kernel
  • Q: Close the pager
  • H: Show keyboard shortcuts
  • P: Open the command palette

Edit Mode Shortcuts (press Enter to enable)

  • Tab: Code completion or indent
  • Shift + Tab: Tooltip
  • Ctrl + ]: Indent
  • Ctrl + [: Dedent
  • Ctrl + A: Select all
  • Ctrl + Z: Undo
  • Ctrl + Shift + Z: Redo
  • Ctrl + Y: Redo
  • Ctrl + Home: Go to cell start
  • Ctrl + End: Go to cell end
  • Ctrl + Left: Move cursor left one word
  • Ctrl + Right: Move cursor right one word
  • Ctrl + Shift + P: Open the command palette
  • Esc: Command mode
  • Ctrl + M: Command mode
  • Shift + Enter: Run cell, select below
  • Ctrl + Enter: Run cell
  • Alt + Enter: Run cell, insert below

Markdown Cells

  • Ctrl + 1: Convert to heading 1
  • Ctrl + 2: Convert to heading 2
  • Ctrl + 3: Convert to heading 3
  • Ctrl + 4: Convert to heading 4
  • Ctrl + 5: Convert to heading 5
  • Ctrl + 6: Convert to heading 6
  • Ctrl + M, M: Convert to markdown
  • Ctrl + M, Y: Convert to code

Navigation

  • Ctrl + Shift + -: Split cell at cursor
  • Ctrl + Up: Move cursor to cell start
  • Ctrl + Down: Move cursor to cell end
  • Ctrl + Shift + Up: Select to cell start
  • Ctrl + Shift + Down: Select to cell end

Kernel

  • Ctrl + .: Restart kernel
  • Ctrl + Alt + .: Interrupt kernel
  • Ctrl + Shift + .: Restart kernel and clear output
@pizofreude
Copy link
Author

pizofreude commented Jul 11, 2025

Using R with Jupter lab or notebook

The steps to use R with Jupyter Notebook are largely the same as for Jupyter Lab. Both Jupyter Notebook and Jupyter Lab rely on Jupyter kernels to support different programming languages, and for R, you use the IRkernel.

Summary:

To use R in Jupyter Notebook, follow these main steps:

  1. Install R on your system (if not already installed).
  2. Install the required R packages:
    install.packages(c('repr', 'IRdisplay', 'evaluate', 'crayon', 'pbdZMQ', 'devtools', 'uuid', 'digest'))
    devtools::install_github('IRkernel/IRkernel')

OR using renv package manager:

  • Initialize renv project: renv::init()
  • Install packages with renv:
     renv::install(c('repr', 'IRdisplay', 'evaluate', 'crayon', 'pbdZMQ', 'devtools', 'uuid', 'digest'))
  • Install IRkernel via renv: renv::install("IRkernel")
  1. Install the R kernel for Jupyter:

    IRkernel::installspec()
    # or for all users (requires admin rights):
    IRkernel::installspec(user = FALSE)

    If using renv: Snapshot dependencies -> renv::snapshot()

  2. Launch Jupyter Notebook:

    • In your terminal or command prompt, run:
      jupyter notebook
  3. In the Jupyter Notebook interface, select New > R to start a new R notebook.

Differences (minor):

Feature Jupyter Notebook Jupyter Lab
Interface Classic notebook interface More modern, modular interface
New R Notebook Location File > New Notebook > R Launcher or File > New > R Notebook
Extensions Limited Rich extension support

So, the core setup (installing IRkernel) is identical. The only difference is in how you interact with the interface once the kernel is installed.

For both environments, ensure that your jupyter command is aware of the R kernel, which the IRkernel::installspec() command handles.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment