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.
$\begingroup$
$\endgroup$
2
-
$\begingroup$ 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.)? $\endgroup$– Mr.WizardFeb 18, 2015 at 18:01
-
$\begingroup$ Both or either would be nice. $\endgroup$– M.R.Feb 18, 2015 at 20:11
Add a comment
|
1 Answer
$\begingroup$
$\endgroup$
4
I achieved my goal with this code in MenuSetup.tr. Here is copy-cell-style:
MenuItem["Copy Cell Style",
FrontEndExecute[{FrontEnd`SelectionMove[FrontEnd`EvaluationNotebook[], All, FrontEnd`EvaluationCell],
KernelExecute[
$mystyle = FrontEndExecute[FrontEnd`NotebookRead[FrontEnd`EvaluationNotebook[]]];
$mystyle = $mystyle[[2]];
]
}],
MenuKey["c", Modifiers -> {"Command", "Shift"}], MenuEvaluator -> "Local"]
and paste-cell-style:
MenuItem["Paste Cell Style",
FrontEndExecute[{FrontEnd`SelectionMove[FrontEnd`EvaluationNotebook[], All, FrontEnd`EvaluationCell],
KernelExecute[
$mycell = FrontEndExecute[FrontEnd`NotebookRead[FrontEnd`EvaluationNotebook[]]];
$mycell = $mycell[[1]];FrontEndExecute[FrontEnd`NotebookWrite[FrontEnd`EvaluationNotebook[],Cell[$mycell,$mystyle]]];
]
}],
MenuKey["v", Modifiers -> {"Command", "Shift"}], MenuEvaluator -> "Local"]
-
1$\begingroup$ @Mr.Wizard In conclusion, we can only use
System
calls likeSet[]
friends insideKernelExecute
, and we can only useFrontend
calls insideFrontEndExecute
, and these might have to be wrapped inside each-other depending on context... $\endgroup$– M.R.Feb 23, 2015 at 16:36 -
-
-
$\begingroup$ For what it's worth I find it useful and you have my vote on both question and answer. $\endgroup$ May 15, 2015 at 7:39