The correct way to do this is in bpirvu's buried answer to How do I change the autoindent to 2 space in IPython notebook:
Just edit ~/.jupyter/nbconfig/notebook.json
. Here is a complete notebook.json
which includes the relevant setting:
{
"CodeCell": {
"cm_config": {
"indentUnit": 2
}
}
}
There's also a more hacky solution that's more prevalent around the web, probably because the Jupyter documentation is lacking on this topic and indentUnit
is only mentioned here: http://jupyter-notebook.readthedocs.io/en/latest/frontend_config.html. This solution is to open your browser's JavaScript console and enter
var cell = Jupyter.notebook.get_selected_cell();
var config = cell.config;
var patch = {
CodeCell:{
cm_config:{indentUnit:2}
}
}
config.update(patch)
which ends up editing ~/.jupyter/nbconfig/notebook.json
for you.