Is there a way to force/control indentation in a multiline comment within an INPUT CELL?

I often end up with some random indentation like the following. I know if I move the comment to a different cell and change the display type (e.g., to CODE) there are less issues but I like to keep the comments in the INPUT cell with the related code for ease of use.

ref = Import["reference.dat", "Table"]\[Transpose];
meas = Import["measure.dat", "Table"]\[Transpose];
  day1 = 3432000
       day2 = 3312000
         day3 = 3312000
            day4 = 3264000
           day5 = 3312000
    day6 = 3312000
  • 1
    $\begingroup$ You could try using \[NewLine] instead of return at the end of each line. On a mac, this character can be entered using Ctrl Option Return. $\endgroup$
    – Carl Woll
    May 25, 2023 at 16:23

1 Answer 1


Yes, there is a very simple way to gain complete control over indentation in comments.

Just get into the habit of starting every comment with


rather than


Then you can indent to your heart's content using space characters at the start of a line. If you don't want to indent at all, don't use any. Problem solved!

  • $\begingroup$ This is brilliant - a one-character solution to an irritating problem :-) $\endgroup$ Nov 7, 2023 at 13:39
  • $\begingroup$ Perfect. Confirmed that this works for me. $\endgroup$
    – OpticsMan
    Nov 7, 2023 at 23:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.