asPlankBridge
asPlankBridge

Reputation: 1082

How to enable line numbers in IPython notebook 3

I want to enable line wrapping and line numbering by default in my IPython notebook. Until recently it all worked well with the answer given in e.g. this post:

How to display line numbers in IPython Notebook code cell by default

Since I updated my IPython notebook to version 3, this setting seems to be ignored. Could you give me a hint on how to enable line wrapping and line numbering in the current version of IPython? My browser mentions a JavaScript error : Uncaught TypeError: Cannot read property 'options_default' of undefined

Thank you!

Upvotes: 1

Views: 235

Answers (1)

asPlankBridge
asPlankBridge

Reputation: 1082

I found the answer after looking a bit through the JavaScript console. When you update your IPython notebook from version 2 to 3, and you want line numbers and line wrapping, then change your custom.js content to:

 $([IPython.events]).on('app_initialized.NotebookApp', function(){
    IPython.CodeCell.options_default.cm_config.lineWrapping = true;
    IPython.CodeCell.options_default.cm_config.lineNumbers = true;
 });

Upvotes: 1

Related Questions