Doug
Doug

Reputation: 81

How can I prevent output lines from wrapping in VS Code Jupyter Notebooks?

When using Jupyter Notebooks within VS Code is it possible to stop the code cell result text from wrapping?

When querying wide dataframes (Eg 100 columns wide) the resulting text is unreadable due to the text wrapping and requires copying out to other text editors to be able to read the results.

Attached is a screenshot of a simple dataframe header that is wrapping over a couple of lines, once you're returning actual rows it's unusable.

Screenshot

Upvotes: 8

Views: 4509

Answers (2)

starball
starball

Reputation: 50315

To disable word wrapping in the output of a Jupyter Notebook in VS Code, put the following in your settings.json file:

"notebook.output.wordWrap": false,

Actually, the default value of the setting is false, so check if you have set it anywhere in your settings.json to true, and you should be able to remove that line to achieve the same thing.

If you're interested in a feature to make the word wrapping follow the current toggle of source code word wrapping (which is toggled by alt+z), see this issue ticket: Notebook text output should support the word wrap setting #116355, which you can support by giving a thumbs up reaction, and subscribe to get notified about discussion and updates (but please avoid making noisy comments like "+1" / "bump").

Upvotes: 4

Mia Wu-MSFT
Mia Wu-MSFT

Reputation: 366

This could be a limitation of Jupyter's UI. I recommend you to see your data in variable explorer and data viewer. By clicking the Variables icon in the top side after running, you'll see a list of the current variables. For additional information of the variables, you can double-click on a row or use the Show variable in data viewer button to see a more detailed view.

enter image description here enter image description here

Upvotes: 1

Related Questions