[IPython-User] navigating history in notebook

Zoltán Vörös zvoros@gmail....
Sat Jun 30 01:24:43 CDT 2012

Hi All,

I would like to ask if there is a way of navigating in history in the 
notebook. I understand that I can press the up arrow, and then the 
prompt is moved to the cell above, but I don't see how to stay on the 
same cell, and have the earlier commands in it, as in the command line 
console. A use case would be sequential plotting, when one needs all the 
plots, but there is only a small change in the commands generating the 

Now, I have looked into notebook.js, and it seems to me that there was 
some thought given to this scenario, namely, from the lines

if (event.which === key.UPARROW && !event.shiftKey) {
                 var cell = that.get_selected_cell();
                 if (cell.at_top()) {

I would draw the conclusion that there sh/could be a case that looks like

if (event.which === key.UPARROW && event.shiftKey) {

Such a case could facilitate what I was trying to describe above.

The problem I see is the following. Since the notebook does not know 
about the history of the kernel, if such a thing is implemented in the 
notebook, then one would get the content of the cells in the order shown 
in the notebook, and not necessarily in the order in which they were 
executed. (It would be fine with me, though.) However, in the notebook I 
don't find a mechanism for getting the content of a cell which is, say, 
3 cells above the current cell, so I don't know how one could easily 
work their way up the cell sequence, while keeping the cursor in the 
last cell. There is a function select_prev(), but it does what it says, 
gets the previous cell. For the particular problem I faced, this would 
be OK, but being able to move up by one cell only would be somewhat 
awkward, I feel...

An alternative would be using the kernel history, but I don't know if 
the javascript code could be made aware of that.

Could someone comment on this? First, whether there would be any point 
in implementing such a feature. Second, how and where the thing should 
be implemented.


More information about the IPython-User mailing list