2016-11-25 57 views

回答

0

正确的方式做,这是bpirvu的葬回答How do I change the autoindent to 2 space in IPython notebook

只要编辑~/.jupyter/nbconfig/notebook.json。下面是一个完整notebook.json其中包括相关设置:

{ 
    "CodeCell": { 
    "cm_config": { 
     "indentUnit": 2 
    } 
    } 
} 

还有一个更哈克解决方案,它在网络上越来越普遍,可能是因为缺乏关于这一主题的Jupyter文档和indentUnit只是这里提到:http://jupyter-notebook.readthedocs.io/en/latest/frontend_config.html。该解决方案是打开浏览器的JavaScript控制台,然后输入

var cell = Jupyter.notebook.get_selected_cell(); 
var config = cell.config; 
var patch = { 
     CodeCell:{ 
     cm_config:{indentUnit:2} 
     } 
    } 
config.update(patch) 

这最终编辑~/.jupyter/nbconfig/notebook.json你。

+0

试图第二控制台溶液产生以下错误对我来说:'未捕获的类型错误:config.update不是一个函数;在:8:8;'。咩。 – xtian