Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Line wrapping #106

Closed
hellpanderrr opened this issue May 21, 2015 · 13 comments
Closed

Line wrapping #106

hellpanderrr opened this issue May 21, 2015 · 13 comments

Comments

@hellpanderrr
Copy link

I've updated ipython-notebook to Jupyter and noticed that code wrapping in cells is turned off now. In previous version you could turn it on by adding line
IPython.Cell.options_default.cm_config.lineWrapping = true;
to the custom.js, but now this doesn't help. Javascript console shows that there no such parameters as lineWrapping (and lineNumbers also) for the cm_config.
Was this feature moved somewhere (or removed) or is this a problem with my installation?

@Carreau
Copy link
Member

Carreau commented May 21, 2015

Well, it does work for me, but you are probably hitting a race condition as you are accessing the IPython global.

  1. it is better to change module values by actually requiring them, to be sure they are loaded in custom,js:
require(['notebook/js/cell'], function(cell){
    cell.Cell.options_default.cm_config.lineWrapping = true
})
  1. the better option woudl be to persist the config of line wrapping through the API (in flux):
IPython.notebook.get_cell(0).class_config.set('cm_config',{'lineWrapping':true})

@takluyver we don't seem to expose the class_config on the class which prevent to do require([codecell], function(modify config)). Am I mistaking? Should we allow that ?

@takluyver
Copy link
Member

I don't think there's a good way to expose it on the class, because it relies on the ConfigSection instance created by main.js and passed in when instantiating Cell. In this case, class_config means 'config relevant to instances of this class', not 'config which is accessed on the class object'.

@minrk
Copy link
Member

minrk commented Sep 11, 2015

@takluyver @Carreau does this work if specified via the frontend-config API?

@Carreau Carreau self-assigned this Sep 11, 2015
@Carreau
Copy link
Member

Carreau commented Sep 11, 2015

I'm not sure I'll try to have a look, assigning to myself.

@Carreau
Copy link
Member

Carreau commented Sep 11, 2015

@takluyver @Carreau does this work if specified via the frontend-config API?

IPython.notebook.get_selected_cell().class_config.set('cm_config',{'lineWrapping':true}) // or false

Yes it does work independently for markdown cells and code cell and end up as the following in config:

$ cat ~/.jupyter/nbconfig/notebook.json
{
  "MarkdownCell": {
    "cm_config": {
      "lineWrapping": false
    }
  },
  "CodeCell": {
    "cm_config": {
      "lineWrapping": false
    }
  },
}

@Carreau Carreau closed this as completed Sep 11, 2015
@scharfmn
Copy link

IPython.notebook.get_selected_cell().class_config.set('cm_config',{'lineWrapping':true}) // or false

Does not work for me.
IPython 4.0.0
Jupyter 1.0.0
Python 2.7.10 |Anaconda 2.3.0 (x86_64)| (default, May 28 2015, 17:04:42)

 ~/.jupyter/nbconfig/notebook.json 

does not exist for me. I have

 ~/.jupyter/migrated

@Carreau
Copy link
Member

Carreau commented Sep 12, 2015

Does not work for me.

Where did you do that ?
Did it gave errors?

  • in the js console ?
  • in the terminal ?

Did you reload the page ?
Did you restart the server ?

@scharfmn
Copy link

I put this

IPython.notebook.get_selected_cell().class_config.set('cm_config',{'lineWrapping':true}) // or false

into custom.js, as in the old version.

I did restart the server. What happened was: no wrapping, but then when I would try to execute cells that had long lines, I would get a python syntax error where there wasn't one before, with the interpreter giving the same kind of complaint as when one does a line-break without a \.

@Carreau
Copy link
Member

Carreau commented Sep 12, 2015

No you need to execute that only once in the js console of the browser. Not in custom.js

@scharfmn
Copy link

Got it - thank you very much indeed.

@minrk minrk added this to the no action milestone Dec 14, 2015
@DieselAnalytics
Copy link

Is it possible to turn line wrapping on via the %config magic? If so could you please share the code to do so?

@JRKelly
Copy link

JRKelly commented May 15, 2017

No you need to execute that only once in the js console of the browser. Not in custom.js

That browser console says it does not recognize Ipython. Not being familiar with that environment, how do I make it aware of IPython?

@takluyver
Copy link
Member

  • Ensure you are on a tab with a notebook open
  • It is case sensitive
  • At some point in the future, you may need to use Jupyter instead of IPython. For the moment, IPython still works, at least for me, as an alias.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants