3
$\begingroup$

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.

$\endgroup$
0

2 Answers 2

9
$\begingroup$

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

$\endgroup$
1
$\begingroup$

See this. Change

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

to

FrontEnd`SelectionMove[FrontEnd`SelectedNotebook[], Next, Cell]
$\endgroup$
2
  • $\begingroup$ I did not get this, what exactly it does in a code? $\endgroup$
    – acoustics
    Commented Dec 20, 2018 at 4:17
  • $\begingroup$ 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. $\endgroup$ Commented Dec 20, 2018 at 4:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.