I tried assigning two different shortcuts to inserting powers of ten:
command-sequence math-insert 10^{ }; up;
math-insert 10^{ }
However, if I select some text and then use one of the shortcuts, the selected text is replaced instead of being used as the superscript content.
In contrast, a "system-defined" math-insert command such as math-insert \hat does work both ways: if nothing is selected, a hat is inserted and the cursor is placed under the hat; if any text is selected, it is moved under the hat.
How can I make use of selected text when creating custom commands and command sequences?
EDIT: Curiously, this underbrace sequence works too
command-sequence math-insert \underbrace; char-forward; math-subscript;
unlike the power-of-ten example.
\hatwork flawlessly – Sparkler Dec 04 '15 at 02:31