'Enable word wrap in JupyterLab code editor

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
    }
  }


Solution 1:[1]

Try the following,

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

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

Solution 2:[2]

if you looking for here is how I solved it :

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

{"codeCellConfig": {
        
        "lineWrap": "on",
        
    },}

Solution 3:[3]

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Alex Ioannides
Solution 2 Ayoub EL MAJJODI
Solution 3 DharmanBot