I use some custom shortcut keys in KeyEventTranslations.tr
. One is for the Delete All Output
function:
Item[KeyEvent["w", Modifiers -> {Control}],
FrontEnd`FrontEndExecute[FrontEnd`FrontEndToken["DeleteGeneratedCells"]]]
or simply:
Item[KeyEvent["w", Modifiers -> {Control}], "DeleteGeneratedCells"]
This works as expected, putting up the dialog: "Do you really want to delete all the output cells in the notebook?". Is there any way to set up KeyEventTranslations.tr
that when I hit Ctrl+w the dialog is automatically acknowledged and I don't have to hit Enter? The same goes for the Quit kernel
function, that also puts up a dialog.
Answer
Try using this:
FrontEndExecute[
{FrontEnd`NotebookFind[FrontEnd`SelectedNotebook[],
"Output", All, CellStyle, AutoScroll->False],
FrontEnd`FrontEndToken["Clear"]}]
(Untested in KeyEventTranslations.tr
, but works as a button!)
Regarding automating confirming the dialog---I don't think it is possible from within Mathematica. I'd like to note though that you can press Space to confirm the dialog (instead of using Enter), which is considerably easier for me due to the size and position of the key.
Update: As Albert Retey pointed out in a comment, this will only remove output cells, but not "Message"
or "Print"
cells. Those need to be added separately to the command, and this is still a workaround to finding all GeneratedCell
s.
Comments
Post a Comment