Jupyterlab 正在像这样进行软包装(使用设置 "lineWrap": "on"
):
但我更喜欢这样的东西,就像我在所有其他文本编辑器(emacs、intellij、vim...)中都有它一样:
这可能吗? :)
最佳答案
JupyterLab 正在使用 CodeMirror,并且有一个用于缩进软包装行的 hack,发表于 https://codemirror.net/demo/indentwrap.html .
该页面的代码:
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
lineNumbers: true,
lineWrapping: true,
mode: "text/html"
});
var charWidth = editor.defaultCharWidth(), basePadding = 4;
editor.on("renderLine", function(cm, line, elt) {
var off = CodeMirror.countColumn(line.text, null, cm.getOption("tabSize")) * charWidth;
elt.style.textIndent = "-" + off + "px";
elt.style.paddingLeft = (basePadding + off) + "px";
});
editor.refresh();
这只是第一步,我不知道如何在 JupyterLab 中应用该技巧(因为 CodeMirror
在该环境中不是全局变量)。我希望有人能够在此基础上进行构建...
关于python - jupyter lab 中的缩进自动换行是否可行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56969431/