CentAu
CentAu

Reputation: 11160

IPython 5, key for executing block of code instead of inserting new line

The "Enter" key in new IPython versions (5+) inserts a line break instead of executing the current block of code (e.g. inside a function definition); to execute the code block you have to navigate the cursor to the last line and then hit "Enter". In older version hitting "Enter" would directly execute the block. How can we execute the current code from the current cursor location without navigating to the end?

The following image shows what I mean, the curser is at the end of the line b=20, I want to execute this block of code without having to navigate the cursor to the end of the next line. Is there a way to achieve this?

enter image description here

Upvotes: 11

Views: 2436

Answers (2)

Andy
Andy

Reputation: 181

Alt + Enter or Esc + Enter execute the current code block, regardless of cursor position.

Upvotes: 14

Matthew
Matthew

Reputation: 427

Esc + Enter execute the block of code.

Upvotes: 9

Related Questions