3

Is there any keyboard shortcut key to delete the output of a particular cell in Mathematica.

Suppose if I am in a particular cell, and the cell has some output and If use some keyboard shortcut like Ctrl+d, I should be able to delete the output of that particular cell.

Kuba
  • 136,707
  • 13
  • 279
  • 740
acoustics
  • 1,709
  • 9
  • 20

2 Answers2

9

There is too much burden attached to working with KeyEvenTranslations.tr so I rarely use it.

You can try an alternative: DevTools`:NotebookActions:

ResourceFunction["GitHubInstall"]["kubapod", "devtools"]
Needs @ "DevTools`";

NotebookActionsEnable[];

EditNotebookActions[];

add a cell with:

<| "Label" -> "ClearCell"
 , "ShortKey" -> "c"
 , "Action" :> FrontEndExecute[{
     SelectionMove[InputNotebook[],All,CellContents]
   , NotebookDelete @ InputNotebook[]
   }]
|>

Press Save and Test.

And you are ready to go: Ctrl+, and then c should clear cell contents.

enter image description here

Kuba
  • 136,707
  • 13
  • 279
  • 740
1

See this. Change

FrontEnd`SelectionMove[FrontEnd`SelectedNotebook[], All, Cell]

to

FrontEnd`SelectionMove[FrontEnd`SelectedNotebook[], Next, Cell]
Rohit Namjoshi
  • 10,212
  • 6
  • 16
  • 67
  • I did not get this, what exactly it does in a code? – acoustics Dec 20 '18 at 04:17
  • As mentioned in this answer. The shortcut definition has to be added to the file KeyEventTranslations.tr. Also mentioned in that answer is this link which shows how to modify that file the right way. All the information you need is available in the links I have provided and the code modification in the answer above. Try it and if you are still unable to get it to work, add a comment and I will try to help out. – Rohit Namjoshi Dec 20 '18 at 04:41