javascript - 更改 CodeMirror Python 的缩进单位

标签 javascript python codemirror

我没有找到将缩进单位更改为两个空格或最好的方法,让它自动检测单位:http://codemirror.net/mode/python/index.html

enter image description here

如您所见,if 显示已读,因为它获得了 cm-error 类。它有两个空格的缩进。但 print 没问题。尽管此代码块工作正常。

所以:

  1. 有没有办法让代码使用两空格缩进?

  2. 是否可以制作自动缩进装置?

我尝试玩弄 http://codemirror.net/mode/python/python.js无法得出任何结论。

最佳答案

请参阅indentUnit选项。库中没有自动检测功能,但您也许可以编写一个小脚本来查找比上面的缩进更多的第一行,并将差异作为可能的猜测。

关于javascript - 更改 CodeMirror Python 的缩进单位,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35054115/

相关文章:

javascript - Anchor Onclick Division Highlight

python - 亚马逊搜索 API

javascript - 在 CodeMirror textarea 中放置超链接

javascript - 使用 codeigniter MVC 插入到数据库 mysql 后立即显示数据

javascript - Fabric 3.4.0 文本格式

python - 了解 pandas 中的 groupby

带有 CodeMirror 的 Extjs 选项卡面板

css - 代码镜像光标位置偏移

javascript - 添加启动延迟

python - tkinter Treeview 所选项目的点击事件