# How to change indent in notebook input cell without shifting the whole code to the right?

V 12.1 on windows.

This is easier shown in pictures. I like to have large indent for If and Do etc... to make it more clear. But the option LineIndent increases the indent for the whole code to the right, and very little for the stuff I am interested in, which is If, Do etc...

The default LineIndent is 1. Here are 3 pictures showing what happens when changing this from 1 to 2 to 3. Notice how the whole code shifts to the right. I do not want this. I want only to change the indent of these constructs above, inside the code. But without that initial indent added. Even though the indent for If has increased, but it has not increased by same proportion as the whole shift that happens.

So I really want is the following (which I did manually for illustration)

To get close to the above using LineIndent this is the result. You can see how much the whole code shifted to the right due to that initial indent, which I do not want

I played with some of the options in option inspector, but can't figure which will do what I want, if any

I know I can use code cell and do my own formatting, but code cells have its own issues as well.

Is there a setting that will change line indent, but without adding that initial indent? I do not like the whole code shifting so much to the right.

Here is the code used above

foo := Module[{x, y, m},
x = 1;
If[x == 1,
Print["x=1"]
,
Print["x is not 1"]
];

Do[
x = 1
, {m, 1, 10}
];

y
]

• I believe your initial indent includes both the indent for := as well as the indent for Module. I don't think there is a way to change this. May 27, 2020 at 23:25