How can I set up Jupyter Notebook to wrap text in all cells?

I would like to be able to wrap text in my Jupyter Notebook cells. I’m using Windows 10 and I can see advice on how to do this on some other websites, but unfortunately I don’t understand the instructions and I do not have the status required to ask the original posters to clarify. They look like they are for use with Linux and they tell me to edit or perhaps even create a json file called nbconfig. I can’t tell exactly, and I have never edited a json file. More importantly, I can’t tell where I am supposed to enter these commands. Please can you provide me with some step by step instructions on how to do this with Anaconda Navigator on Windows 10? I would really appreciate it, especially since it looks like knowing how to do this will enable me to change other settings in Jupyter Notebook in the future.
Thank you very much for your assistance.

I figured out on my that I could edit the notebook.json file directly in Visual Studio Code, and I thought I would share how I did it here in case others are confused. I used code from this post:


First I found the file in the directory that looks like this: /home/username/anaconda3/etc/jupyter/nbconfig/notebook.json
Then I inserted this code:
{
“Cell”: {
“cm_config”: {
“lineWrapping”: true
}
}
}
You can also specify only code cells or only Markdown cells, as described on Stack Overflow, by including either of the following:

{
  "MarkdownCell": {
    "cm_config": {
      "lineWrapping": true
    }
  },
  "CodeCell": {
    "cm_config": {
      "lineWrapping": true
    }
  }
}

If you have something else in it, ensure you have valid JSON with no trailing commas after } s.

After editing notebook.json, restart Jupyter and reload your notebook.
If you don’t have Visual Studio Code you can probably open and edit it as a text file.

1 Like

Thanks man,

You saved me a great lot of time.

Jupyter Notebook in Visual Studio Code is one of the great things that happen to VSCode community.

Using this config, it is very easy to run code snippets in the VS Code instead of the Jupyter Notebook.

Thanks again,

1 Like

Thank you. This worked for me first time after I made the change and restarted the kernel in my client. I did not have to restart the server because this is a change in the client-side rendering configuration.

Remember that the change must be made in individual conda or pip-venv environments wherever Jupyter Classic NB or JupyterLab is installed.

You can use the path to find them:

/home/username/anaconda3/etc/jupyter/nbconfig/notebook.json

For example, for JupyterLab in one of my conda environments:

“C:\ProgramData\Anaconda3\envs\webscrapers\etc\jupyter\jupyter_notebook_config.d\jupyterlab.json”

The original file contained this:

{
  "NotebookApp": {
    "nbserver_extensions": {
      "jupyterlab": true
}

Adding to the JSON, make sure to add a comma “,” after the last curly brace in the original file, so that you have a valid JSON string object.

The final file contained this:

{
  "NotebookApp": {
    "nbserver_extensions": {
      "jupyterlab": true
    }
  },
  "MarkdownCell": {
    "cm_config": {
      "lineWrapping": true
    }
  },
  "CodeCell": {
    "cm_config": {
      "lineWrapping": true
    }
  }
}

Thank you for putting me on the right track here !!

1 Like

Do you know where I can find all the possible Json code for affecting cells like scrolling, hiding and others. thanks for sharing the linewrapper @V-Talbot !