To help illustrate my problem, consider the following cell:
First thing to notice is that there is syntax highlighting. Second, I can pretty print mathematics; that is, I see $x^2$ instead of x^2
. Finally, the equal signs are aligned "nicely." I will expand on what I mean by "nicely" in a second.
As of now, I have no idea how to create the cell I illustrated above. Let me elucidate what I mean by this. By default the "Style of newly typed cells" is Input
and the "Format type of new input cells" is StandardForm
(in V9 you can see this in the Preferences -> Evaluation menu).
To create a cell that is similar, but not exact, to the cell I have shown above, I need to type the following:
variable Space = Space 1 ; Enter
var Space x 13 = Space x Ctrl + 6 2 → ;
This produces the following. Notice that the equal signs are not quite aligned.
Hitting Space 13 times is not what I call a "nice" way of aligning the equal signs. What I expect, is to hit Space 6 times to align the equal signs since this is a monospace font.
Question: Is there a way to modify the FrontEnd so that the sequence of keyboard commands:
variable Space = Space 1 ; Enter
var Space x 6 = Space x Ctrl + 6 2 → ;
produces the first image above and I am able to evaluate it?
Let me explain what I have tried so far.
(Attempt 1) Changing "Format type of new input cells" to InputType
. Using the second set of keyboard commands above, I get what is desired, but evaluating the cell gives me an error.
MakeExpression::boxfmt: InputForm in MakeExpression[FormBox[RowBox[{RowBox[{variable,=,1}],;}],InputForm],InputForm] is not a box formatting type. A box formatting type is any member of $BoxForms. >>
(Attempt 2) Changing "Format type of new input cells" to Raw InputType
. I try using the second set of keyboard commands above and can align the equal signs, but I lose the ability to pretty print math and lose syntax highlighting. I am able to evaluate the cell.
(Attempt 3) Keeping "Format type of new input cells" as StandardForm
. I use the first set of keyboard commands to produce the third image. Then I highlight the cell bracket and convert to InputForm
(via Shift + Ctrl + I). This gives the following.
I can then add a few spaces to align the equal signs.
Then I change the x^2
to a $x^2$. Unlike in (Attempt 1), I can evaluate this cell. Even though this gives me what I desire, it is a tedious way to go about it.
ManualInput
style proposed in that answer does not solve my problem. Although you do mention the behavior of theCode
style. $\endgroup$