18

I would like to enable word wrap for the code cells in jupyterlab, but do not manage to find how.

Already tried:

  • File --> Settings --> Text Editor --> User Overrides:{"lineWrap": true}, which toggles the greyed-out "word wrap" in the "Editor" menu, but does not solve my problem
  • This code also did not work (neither did simply "Cell": {...} ):
"CodeCell": {
    "cm_config": {
      "lineWrapping": true
    }
  }
Borislav Aymaliev
  • 803
  • 2
  • 9
  • 20

3 Answers3

14

Try the following,

{
   "codeCellConfig": {
      "lineWrap": "wordWrapColumn",
      "wordWrapColumn": 80
   }
}

For reference, see this pull request from the JupyterLap project on GitHub.

Alex Ioannides
  • 1,204
  • 9
  • 10
  • 2
    I guess this was implemented since January. Just `"lineWrap": "on"` did the trick for me, but generally your answer is correct. Thank you for the reminder. – Borislav Aymaliev Oct 30 '18 at 13:38
  • Any chance that you know how to enable text wrapping on google colaboratory jupyter notebook? I have updated to the latest notebook: (5.7.8) but no text wrap option on text output is available on colaboratory. – pleabargain Apr 15 '19 at 06:27
  • Sorry, but I can't help you there. – Alex Ioannides Apr 22 '19 at 19:06
  • [This thread](https://stackoverflow.com/questions/58768173/how-to-wrap-code-in-cells-on-jupyterlab-version-1-1-4) helped me to figure out where to put the settings. – panc Feb 08 '21 at 21:52
7

Here is how I solved it :

Settings -> Advanced Settings Editor -> Notebook to user preferences add

{"codeCellConfig": {
        
        "lineWrap": "on",
        
    },}
Ayoub EL MAJJODI
  • 161
  • 1
  • 10
1

Working as of 1 May 2022 for JupyterLab v3.2.1

I feel that the answer above is not clear enough, and hope to provide a quick solution for those who visit this page in the future.

How to enable word wrap in JupyterLab

  1. Click on Settings > Advanced Settings Editor > Select Notebook (at the sidebar)
  2. On the User Preferences tab, enter the following to enable word wrap
{
    "codeCellConfig":{
         "lineWrap": "on"
    }
}

Before

enter image description here

After

enter image description here

DharmanBot
  • 1,066
  • 2
  • 6
  • 10
cyberjj999
  • 27
  • 1
  • 6