Dharma
Dharma

Reputation: 2643

ipython notebook clear all code

All I want to do is try some new codes in ipython notebook and I don't want to save it every time as its done automatically. Instead what I want is clear all the codes of ipython notebook along with reset of variables.

I want to do some coding and clear everything and start coding another set of codes without going to new python portion and without saving the current code.

Any shortcuts will be appreciated.

Note: I want to clear every cells code one time. All I want is an interface which appears when i create new python file, but I don't want to save my current code.

Upvotes: 9

Views: 16252

Answers (6)

Achal_Jain
Achal_Jain

Reputation: 1

Just do Ctrl+A , this selects all the individual blocks/cells and then press d twice.

Upvotes: 0

pylang
pylang

Reputation: 44455

In Jupyter, do the following to clear all cells:

  1. Press Esc to enter command mode.
  2. Hold Shift. Select the first and last cells to select all cells.*
  3. Press d twice to delete all selected cells.

Alternatively, if you simply want to try out code, consider running the ipython console, which is purely interactive in the REPL and does not require creating a new file. In a command prompt, type:

> ipython

Demo

Click outside the textbox to select a cell in command mode (thanks @moondra's).

Command Mode (Yes)

enter image description here

Edit Mode (No)

enter image description here

Upvotes: 20

JamesSchiiller
JamesSchiiller

Reputation: 83

Press the scissors (cut) button multiple times for each cell you want to delete.

Upvotes: 1

kyasar
kyasar

Reputation: 449

You can type dd to remove current selected cell. And if you continously press dd you can clean the screen.

Upvotes: 1

Rriskit
Rriskit

Reputation: 565

Well, you could use Shift-M to merge the cells (from top) - at least there's only one left to delete manually.

Upvotes: 1

Ginxer
Ginxer

Reputation: 5

Ok youngster, I will break this down for ya in simple steps:

  1. go to the intended textbox and put your mouse cursor there
  2. on keyboard press crtl-a and delete
  3. Ta-dah all done

Glad to help

Upvotes: -3

Related Questions