# How can I copy & paste cell styles?

In Mac's mail app the key shortcut "command + option + c" gives a copy selected text style and "cmd + opt + v" pastes the style. Is there a way to achieve this with cell styles? The keyboard part is solved in this post, I'm just not sure how to effect the "copy-style" part of this problem.

• What exactly do you mean by cell styles? Are you referring to the Stylesheet types accessed in the Format > Style menu, or to formatting applied at the Cell level (font size, background color, etc.)? Feb 18 '15 at 18:01
• Both or either would be nice.
– M.R.
Feb 18 '15 at 20:11

## 1 Answer

I achieved my goal with this code in MenuSetup.tr. Here is copy-cell-style:

MenuItem["Copy Cell Style",
FrontEndExecute[{FrontEndSelectionMove[FrontEndEvaluationNotebook[], All,         FrontEndEvaluationCell],
KernelExecute[
$mystyle = FrontEndExecute[FrontEndNotebookRead[FrontEndEvaluationNotebook[]]];$mystyle = $mystyle[[2]]; ] }], MenuKey["c", Modifiers -> {"Command", "Shift"}], MenuEvaluator -> "Local"]  and paste-cell-style: MenuItem["Paste Cell Style", FrontEndExecute[{FrontEndSelectionMove[FrontEndEvaluationNotebook[], All, FrontEndEvaluationCell], KernelExecute[$mycell = FrontEndExecute[FrontEndNotebookRead[FrontEndEvaluationNotebook[]]];
$mycell =$mycell[[1]];FrontEndExecute[FrontEndNotebookWrite[FrontEndEvaluationNotebook[],Cell[$mycell,$mystyle]]];
]
}],
MenuKey["v", Modifiers -> {"Command", "Shift"}], MenuEvaluator -> "Local"]

• @Mr.Wizard In conclusion, we can only use System calls like Set[] friends inside KernelExecute, and we can only use Frontend calls inside FrontEndExecute, and these might have to be wrapped inside each-other depending on context...
– M.R.
Feb 23 '15 at 16:36
• Does no-one find this useful?
– M.R.
Feb 26 '15 at 22:56
• @anyone hmmmmm?
– M.R.
Mar 3 '15 at 1:42
• For what it's worth I find it useful and you have my vote on both question and answer. May 15 '15 at 7:39