Skip to content

Instantly share code, notes, and snippets.

@kidpixo
Last active April 7, 2024 12:18
Show Gist options
  • Save kidpixo/f4318f8c8143adee5b40 to your computer and use it in GitHub Desktop.
Save kidpixo/f4318f8c8143adee5b40 to your computer and use it in GitHub Desktop.
Keyboard shortcuts for ipython notebook 3.1.0 / jupyter

Warning This is SEVERELY outdated, the current jupyter version is > 6.X, please refer to your current jupyter notebook installation!

Disclaimer : I just copied those shortcuts from Jupyter Menú > Help > Keyboard Shortcuts, I didn't wrote them myself.

Check your current shortcuts in your Help, shortcuts coule have been modified by extensions or your past self.

Toc

Keyboard shortcuts

The IPython Notebook has two different keyboard input modes. Edit mode allows you to type code/text into a cell and is indicated by a green cell border. Command mode binds the keyboard to notebook level actions and is indicated by a grey cell border.

MacOS modifier keys:

  • ⌘ : Command

  • ⌃ : Control

  • ⌥ : Option

  • ⇧ : Shift

  • ↩ : Return

  • ␣ : Space

  • ⇥ : Tab

Command Mode (press Esc to enable)

  • ↩ : enter edit mode

  • ⇧↩ : run cell, select below

  • ⌃↩ : run cell

  • ⌥↩ : run cell, insert below

  • Y : to code

  • M : to markdown

  • R : to raw

  • 1 : to heading 1

  • 2 : to heading 2

  • 3 : to heading 3

  • 4 : to heading 4

  • 5 : to heading 5

  • 6 : to heading 6

  • ↑ : select cell above

  • K : select cell above

  • ↓ : select cell below

  • J : select cell below

  • A : insert cell above

  • B : insert cell below

  • X : cut selected cell

  • C : copy selected cell

  • ⇧V : paste cell above

  • V : paste cell below

  • Z : undo last cell deletion

  • D,D : delete selected cell

  • ⇧M : merge cell below

  • S : Save and Checkpoint

  • ⌘S : Save and Checkpoint

  • L : toggle line numbers

  • O : toggle output

  • ⇧O : toggle output scrolling

  • Esc : close pager

  • Q : close pager

  • H : show keyboard shortcut help dialog

  • I,I : interrupt kernel

  • 0,0 : restart kernel

  • ␣ : scroll down

  • ⇧␣ : scroll up

  • ⇧ : ignore

Edit Mode (press Enter to enable)

  • ⇥ : code completion or indent

  • ⇧⇥ : tooltip

  • ⌘] : indent

  • ⌘[ : dedent

  • ⌘A : select all

  • ⌘Z : undo

  • ⌘⇧Z : redo

  • ⌘Y : redo

  • ⌘↑ : go to cell start

  • ⌘↓ : go to cell end

  • ⌥← : go one word left

  • ⌥→ : go one word right

  • ⌥⌫ : delete word before

  • ⌥⌦ : delete word after

  • Esc : command mode

  • ⌃M : command mode

  • ⇧↩ : run cell, select below

  • ⌃↩ : run cell

  • ⌥↩ : run cell, insert below

  • ⌃⇧subtract : split cell

  • ⌃⇧ : split cell

  • ⌘S : Save and Checkpoint

  • ↑ : move cursor up or previous cell

  • ↓ : move cursor down or next cell

  • ⇧ : ignore

@lindsayad
Copy link

Echo that last question

@danohu
Copy link

danohu commented Feb 10, 2017

It's quite confusing to show these in uppercase. The commands all need to be entered in lowercase, unless they are shown with the shift symbol above!

@daviewales
Copy link

What does D,D mean? Do I just press d then , then d? It doesn't seem to work.

@devinbrady
Copy link

Echoing the question from @daviewales above... not sure how those commands are supposed to work.

@apeltzer
Copy link

You simply double press "D" quickly, at least that works for me ;-)

@jishnudantu
Copy link

Thanks!

@lxkain
Copy link

lxkain commented Nov 30, 2017

I woud love a keyboard shortcut for toggling (showing <-> hiding) code

@rgime
Copy link

rgime commented Mar 15, 2018

There is a shortcut to go to the end of the line ?
I am asking this because of the autocomplete that the cursor stay behind the ) or ]
Like: i type "print(" and automatic put a ")" after the cursor bur i dont wanna type the arrows...
with the print example i need to type only one arrow, but with a lot it be cool a shortcut
Thanks.
Rafael

@kpmiller
Copy link

On my Mac ctrl-e goes to the end of the line, ctrl-a goes to the beginning.

@deliosiret
Copy link

How to switch from tab code completion mode to tab indent mode?

@miskaknapek
Copy link

Very helpful - thanks!

@nate2s
Copy link

nate2s commented Jul 7, 2018

On Mac + Safari, uppercase D,D did not delete, but lowercase d,d did.

@Zack-M
Copy link

Zack-M commented Aug 11, 2018

Is there a keyboard shortcut on MacOS for opening a new notebook on Chrome?

@wuestkamp
Copy link

On my Mac ctrl-e goes to the end of the line, ctrl-a goes to the beginning.
Anyone knows how to customize this to crtl + left-array and crtl + right arrow?

@kidpixo
Copy link
Author

kidpixo commented Oct 17, 2019

On my Mac ctrl-e goes to the end of the line, ctrl-a goes to the beginning.
Anyone knows how to customize this to crtl + left-array and crtl + right arrow?

This is really strange, normally Macs have CMD-left/right arrow == beginning/end of a line.

Yours are gnu readline emacs bindings Readline Cheat Sheet
I now use lambdalisue/jupyter-vim-binding to have Vim bindings in jupyter and don't bother about system shortcuts anymore.

@ahmadko
Copy link

ahmadko commented Jan 10, 2020

I want to assign the combination control and enter to only run current cell instead of running the cell and move to next one, so I'm trying to write in the shortcut editor "Ctrl-Return" but it's taking working, what string should I use? Thnx!

@kidpixo
Copy link
Author

kidpixo commented Jan 10, 2020

@ahmadko I have no idea, did you try to check the official docs?

@ahmadko
Copy link

ahmadko commented Jan 11, 2020

yes, i just restarted the server and was able to use "return" keyword, thanx!

@meetrainier
Copy link

Is there something to comment the selected lines in python code?
Also, I found that a ^d deletes a line.

@kidpixo
Copy link
Author

kidpixo commented Mar 5, 2020

Is there something to comment the selected lines in python code?

@meetrainier no idea, I normally use ⌘ /

Also, I found that a ^d deletes a line.

Uhm not working here, but I'm using lambdalisue/jupyter-vim-binding: Jupyter meets Vim. Vimmer will fall in love..

@rakeshskc
Copy link

Superb, Thanks

@mrbrian1
Copy link

I want to assign the combination control and enter to only run current cell instead of running the cell and move to next one, so I'm trying to write in the shortcut editor "Ctrl-Return" but it's taking working, what string should I use? Thnx!

have you tried "Ctrl-Enter"

@mrajay002
Copy link

as a beginner i was looking for short keys and this one was very helpfull for me.

@supremetrashpanda
Copy link

This is very helpful, Thank you!!

@Prrajugantera
Copy link

H and P command is not working help

@kidpixo
Copy link
Author

kidpixo commented Jun 14, 2021

H and P command is not working help

the disclaimer on the top : Warning This is SEVERELY outdated, the current jupyter version is > 6.X, please refer to your current jupyter notebook installation!

@shiyilin890
Copy link

helpful,thanks

@vatsav-vs
Copy link

very helpful thanks :)

@sampleidgithubkajal
Copy link

helpful

@viethoangdata
Copy link

helpful

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