Clearing Cell Output with Keyboard Shortcut

Hello!

I’m trying to clear my cell’s output using keyboard shortcuts. Online says to enter command mode, then press “O”, but it doesn’t work for me. I tried entering settings to change keyboard shortcuts but “Clear Cell Output” doesn’t appear. Does anybody know why this is happening?

Thank you.

It would be best if you share details of what version of Jupyter you are using?

And please share details of where you mean by ‘Online says’ because that likely needs updating. Or it is for a particular custom offering of Jupyter and/or offering of an older version (see below).


My guess is you are using outdated details and current Jupyter tech. All current Jupyter tech is built on JupyterLab components, see the bottom of the SO answer here for more on that.

I found at least one thread on StackOverflow with outdated and/or unclear details in the thread and so prompted by this post, I added an updated, unified answer there entitled:

Step-by-step: Adding custom shortcuts to clear individual cell output & to clear in the entire notebook for both Jupyter Notebook v7+ and current JupyterLab (JupyterLab 4)

1 Like

Hi Wayne, I am very surprised by how thorough of an investigation and help you gave me. This SO thread was one of the online resources I checked. I followed the step-by-step guide you wrote in SO and it worked perfectly. Thank you! It would be really nice if JupyterLab allowed for directly adding this new shortcut in Keyboard Shortcuts as opposed to writing it as JSON in User Preferences. Nevertheless, thank you so much for promptly answering and giving me such great help.

1 Like

I’m not quite sure which of two things you are interested in urging the developers to do and so I’ll break this into two sections.


Do you mean once you add it, that it show up with indicators as how to do use in the appropriate menu? For example, the the clearing of output, the menu you get when you right click in the notebook page.

There may well be a way, but I haven’t worked out if there is and how yet. For one example of one command that shows up in a menu, I had seen a ‘category’ setting used, but I couldn’t tell if it helps it propagate to the menus or not.

There are several posts and filed issues in relation to keyboard shortcuts but I haven’t found one along this line yet. May not mean there isn’t. I would think this deserves a post of its own somewhere though if you are eager. There was some discussion of a here that leads eventually to this issue.

Yet, at this timeI cannot point you to where you should put in your two cents among the issues on the GitHub page. Maybe a post on this forum highlighting this specific question or a new issue there may lead to some insight?


Or maybe by that comment you were referring to what is discussed here in the comment, “I’m still interested to know if there are plans to let people do this without messing with JSON”?

The situation is much the same although from the general discussion it seems that has more hurdles that would need clearing, and I am also at a loss for where you should put in your two cents on this effort as well. So much of what I wrote above for ideas on how to proceed hold if this better gets at your concern.

Hello Wayne,

Sorry, allow me to clarify what I meant. Before pasting in your JSON that created the shortcut, I tried following this tutorial: Keyboard Shortcuts to Clear Cell Output in Jupyter Notebook - GeeksforGeeks
When I reached this step: [Picture with the orange arrow above the “Clear Current Cell Output” header, couldn’t embed multiple pics as I am a new user]
I saw this, except without the two shortcuts present:


There was nothing when I tried searching for “clear cell outputs”.

Would you like me to clarify what I mean further or am I understood?
Thanks

I see what you mean now.
I think that is covered in this post, which leads here.
You would like anything that is in menu to come up there, I think? And I think that is what this issue is about. You could put in your thinking or a ‘+1’ there.