2016-11-25 440 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