Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Say a have the function foo:

foo[x_] := x + 2

Like the Evalution -> Evaluate in place, I would like to have a keyboard shortcut that replaces the current selection with the result of applying foo to the selection.

For example if I have selected 1+3 in a cell with the following contents:


By pressing a keyboard combination, I want Mathematica to replace it with the result of foo[1+3] (6):

share|improve this question
@Kuba Sorry I think that would be too cumbersome. – Tyilo May 23 '14 at 21:31
up vote 4 down vote accepted

ok, so you need to add this Item.

Item[KeyEvent["t", Modifiers -> {Control}],
                             RowBox[{"foo", "[", "\[SelectionPlaceholder]", "]"}]];
      FrontEnd`SelectionMove[FrontEnd`InputNotebook[], All, Expression, 2];


enter image description here

Select what you need

enter image description here

Use Ctrl+t

enter image description here


Here is a tutorial how to add a new shortcut: Automating Esc [[ Esc formatting?

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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