我想在我的Jupyter筆記本中使用2個空格而不是4個空格的默認縮進大小。我怎樣才能做到這一點?如何在我的Jupyter筆記本中配置縮進大小?
注意:這不是How do I change the autoindent to 2 space in IPython notebook的重複,因爲該問題針對(折舊)IPython筆記本,而不是(當前)Jupyter筆記本。
我想在我的Jupyter筆記本中使用2個空格而不是4個空格的默認縮進大小。我怎樣才能做到這一點?如何在我的Jupyter筆記本中配置縮進大小?
注意:這不是How do I change the autoindent to 2 space in IPython notebook的重複,因爲該問題針對(折舊)IPython筆記本,而不是(當前)Jupyter筆記本。
正確的方式做,這是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
你。
試圖第二控制檯溶液產生以下錯誤對我來說:'未捕獲的類型錯誤:config.update不是一個函數;在:8:8;'。咩。 –
xtian