Defining macros in LyX
LyX uses LaTeX as the backend, so in principle you can use any LaTeX macro in LyX.
For your case, you can go to Document --> Settings --> LaTeX preamble, and add your \newcommand
there. To use it in a document just type \from
, but note that this only works in math mode.
LyX won't necessarily show it formatted as you're typing but it will come up in a PDF export.
LyX includes a feature for inserting macros that if used will (in most cases) replace the defined command with a LyX graphical representation of it's definition.
To use macros, do Insert > Math > Macro
and insert your to be defined command and its content.
Alternatively, or if something goes haywire while the content is being typed, you can write out the entire \newcommand...
in normal text mode, and then in one fell swoop convert it to a macro by highlighting it, and then applying Insert > Math > Inline formula
(or the corresponding keyboard shortcut).