I want to some key combination like CtrlShift+ to insert Print[ ]; into a workbook. I used

 "DuplicatePreviousOutput", {Delimiter, MenuItem["Print[ ];",
 FrontEnd`KernelExecute[nb = SelectedNotebook[];
 NotebookWrite[nb, Cell[BoxData[RowBox[{"Print[ ];"}]], "Input"]];], 
 MenuKey["+", Modifiers -> {"Control", {"Shift"}}], 
 System`MenuEvaluator -> Automatic]}]]

from this answer. It works nicely, but it adds a new item to the insert menu every time I use it. I've tried as many ways as I can think of to simplify the code, but it never works after these changes. I would rather not use the Esc string Esc approach discussed here Escape because it requires several keystrokes.

  • 4
    $\begingroup$ So you want to easily replace functionality for a shortcut? If so, the joker functionality from Shortcuts package should fit your need. Take a look on example: 34159. Is this what you need? $\endgroup$ – Kuba Nov 26 '15 at 15:40
  • $\begingroup$ @Kuba - Yes it works. It nice to also have those other shortcuts. Thanks. $\endgroup$ – George Wolfe Nov 27 '15 at 2:08
  • $\begingroup$ Great :) let's mark it as a duplicate then :) $\endgroup$ – Kuba Nov 27 '15 at 7:12

Browse other questions tagged or ask your own question.