在重新格式化代码时,如何停止PyCharm插入空格进行精确对齐?

2024-10-01 15:43:52 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用制表符缩进我的Python代码,PyCharm非常热衷于使用空格进行精确的对齐,但它不会使代码无效,我想知道如何停止这种行为。在

例如,在这里,除了第一个元素与元素保持对齐之外,在每个元素之前都插入了2个空格。在

INDEXES_TO_ILLUMINANTS = {0: "Unknown",
                          1: "DayLight",
                          2: "Fluorescent",
                          3: "Tungsten (Incandescent Light)",
                          4: "Flash",
                          9: "Fine Weather"}

Tags: to代码元素制表符unknownpycharmflashlight
2条回答

似乎您可以关闭“智能标签”:

  • If this check box is selected, PyCharm inserts tabs for indentation and reformatting, but fine alignment to a necessary column is done only via spaces without replacing them with tabs. This is done in order to preserve visual representation of the source code, when the Tab Size is changed.
  • If this check box is cleared, only tabs are used. This means that a group of spaces that fits the specified tab size is automatically replaced with a tab, which may result in breaking fine alignment.

在PyCharm 5中,“Collections:Align when multiline”设置会添加这些空格:

"Collections: Align when multiline" setting adds those spaces.

相关问题 更多 >

    热门问题