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$
7
$\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

| improve this answer | |
$\endgroup$
1
$\begingroup$

See this. Change

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

to

FrontEnd`SelectionMove[FrontEnd`SelectedNotebook[], Next, Cell]
| improve this answer | |
$\endgroup$
  • $\begingroup$ I did not get this, what exactly it does in a code? $\endgroup$ – acoustics Dec 20 '18 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$ – Rohit Namjoshi Dec 20 '18 at 4:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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