# Apply a style to a selected structure

If I type out, in my notes, a series of transformations, I often like to convert the very last step to a Framed equation:

I'm currently doing this by:

1. selecting the last expression,
2. copying it,
3. pasting it in a new field,
4. adding Framed[ … ] and evaluating,
5. copying the result,
6. pasting it back in the original field.

Is there a hotkey or quick way for me to apply a transformation to a selection, replacing it with the result? (Or something like that.)

Thanks!

• Ctrl+Shift+Enter is the keyboard shortcut for "evaluate in place", which you press after highlighting an expression; this should ease your task. – J. M.'s ennui Sep 6 '17 at 16:13

Ctrl+Shift+Enter is the keyboard shortcut for "evaluate in place", which you press after highlighting an expression; this should ease your task. – J. M.♦ 2 mins ago

Notice I used Defer, it holds its arguments and is stripped when boxes are created. Exactly what we need keep e.g. 1 + 1 in this form.

Related:

How can I change mouse hover behavior for hyperlinks in a notebook?

• Didn't have a computer, so thanks for following through! – J. M.'s ennui Sep 6 '17 at 16:20
• This is excellent, especially with the .gif! Truly concise, helpful answer. <3 – ELLIOTTCABLE Sep 9 '17 at 18:03

You could also use InputAliases. For example:

CurrentValue[EvaluationNotebook[], InputAliases] = {
"fr" -> FrameBox[
"\[SelectionPlaceholder]",
BaselinePosition->Baseline,
Background->LightGray
],
ParentList
};


Here is a short animation using the alias:

One further comment. The difference between the two cases is that the evaluate in place approach used Framed, which by default has the option StripOnInput->False. Using:
10 == Framed[Defer[11-1], StripOnInput->True]