我以前从来没有真正担心过这一点,因为我只(* -- *)
对小注释或注释代码使用内联注释。如果我需要多行注释,我会将我的代码分成更小的部分并使用文本单元格。
也就是说,您可以尝试\[AlignmentMarker]
在最右边使用 s *)
:
1 + 2 + 3 + (* First three \[AlignmentMarker]*)
4 + 5 + 6 + (* Next three \[AlignmentMarker]*)
7 + 8 + 9 (* Last three \[AlignmentMarker]*)
显示为
编辑以回应评论:
如果您在代码之间有注释(左侧没有代码),则可以将其放入 GridBox
(使用Ctrl-Enter
and创建)中,使用白色字体Ctrl-,
注释掉。(* ... *)
很难提供代码来完成上述操作......但这里是 Box 表单:
Cell[BoxData[
RowBox[{"Manipulate", "[", "\[IndentingNewLine]",
RowBox[{RowBox[{RowBox[{"a", " ", "=", " ",
RowBox[{"x", "+", "1"}]}], ";", "\[IndentingNewLine]", " ",
RowBox[{StyleBox["(*", FontColor->GrayLevel[1]], "",
GridBox[{{"(*", RowBox[{"Inter", "-", RowBox[{"code", Cell[""]}]}], "*)"},
{"(*", "comments", "*)"}},
GridBoxAlignment->{"Columns" -> {{Left}}, "ColumnsIndexed" -> {},
"Rows" -> {{Baseline}}, "RowsIndexed" -> {}}], " ",
StyleBox["*)", FontColor->GrayLevel[1]]}], "\[IndentingNewLine]",
RowBox[{"{", RowBox[{"a", ",", SuperscriptBox["a", "2"]}], "}"}]}], ",",
"\[IndentingNewLine]",
RowBox[{"{", RowBox[{"x", ",", "0", ",", "1"}], "}"}]}],
"]"}]], "Input"]