在Jupyter笔记本中,如何将自动缩进更改为制表符而不是4个空格 [英] In Jupyter notebook, how to change auto indent to tab instead of 4 spaces
本文介绍了在Jupyter笔记本中,如何将自动缩进更改为制表符而不是4个空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我刚刚开始使用jupyter笔记本. Google搜索没有帮助.谢谢!
I just started using jupyter notebook. Google search didn't help. Thanks!
更新:答案快速摘要
在启动ipython文件之前,在单元格中运行以下代码已为我完成了任务.一个问题是,我们必须每次为每个文件运行一次.
Running the following code in a cell before you start a ipython file got the task done for me. One problem is that we have to run this everytime for each file.
%%javascript
// apply setting to all current CodeMirror instances
IPython.notebook.get_cells().map(
function(c) { return c.code_mirror.options.indentWithTabs=true; }
);
// make sure new CodeMirror instances created in the future also use this setting
CodeMirror.defaults.indentWithTabs=true;
推荐答案
如果在单元格中运行此javascript代码,则应允许您插入硬标签:
If you run this javascript code in a cell it should allow you to insert hard tabs:
%%javascript
IPython.tab_as_tab_everywhere = function(use_tabs) {
if (use_tabs === undefined) {
use_tabs = true;
}
// apply setting to all current CodeMirror instances
IPython.notebook.get_cells().map(
function(c) { return c.code_mirror.options.indentWithTabs=use_tabs; }
);
// make sure new CodeMirror instances created in the future also use this setting
CodeMirror.defaults.indentWithTabs=use_tabs;
};
IPython.tab_as_tab_everywhere()
对我有用.来源= http://pirsquared.org/blog/indenting-tabs.html
这篇关于在Jupyter笔记本中,如何将自动缩进更改为制表符而不是4个空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文