python - jupyter lab 中的缩进自动换行可能吗?
问题描述
Jupyterlab 正在做这样的软包装(使用设置"lineWrap": "on"
):
但我更喜欢这样的东西,就像我在所有其他文本编辑器(emacs、intellij、vim ...)中都有它一样:
这可能吗?:)
解决方案
JupyterLab is using CodeMirror and there is a hack for indentation of soft-wrap lines, published on https://codemirror.net/demo/indentwrap.html.
Code from that page:
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();
It's just a first step and I have no idea how to apply that hack inside JupyterLab (since CodeMirror
is not a global variable in that environment). I hope someone will be able to build on top of this...
推荐阅读
- python - SQL查询如何使用两个日期变量?'date' 和 regexp_replace('date', '-', ''),1,8)
- r - 在 R 3.6.1 中安装包的问题
- excel - 创建新工作表仅适用于下一个数据,它会引发错误“运行时错误 9”
- php - php中的html表单不从服务器发送到电子邮件
- python - 有什么方法可以从实时视频中提取静止帧
- python - 如何获取dlib中dets的边界框坐标?
- html - VML 背景图像位于 Outlook 底部
- python - 具有动态查询集 ModelMultipleChoiceField 的 Django 表单
- amazon-web-services - 谷歌云登录小部件,如 Facebook
- c++ - 为什么一种基于for循环的范围类型在大括号初始化列表上是非法的c ++