I am using jupyter-notebooks for python coding. Is there a way to wrap text/code in a jupyter notebook code cell?
Picture provided below.
By wrap text means "how text is wrapped in MS-word"
wrap(text, width=70, **kwargs): This function wraps the input paragraph such that each line in the paragraph is at most width characters long. The wrap method returns a list of output lines. The returned list is empty if the wrapped output has no content.
a keyboard shortcut for reformatting the current code-cell (default shortcut is Ctrl-L , can also be configured not to add the keyboard shortcut). a keyboard shortcut for reformatting the whole notebook (default shortcut is Ctrl-Shift-L , can also be configured not to add the keyboard shortcut).
This extension adds codefolding functionality from CodeMirror to a codecell. In edit mode, clicking on the triangle in the gutter (left margin of codecell) or typing the codefolding hotkey (default is Alt+F ), folds the code. In command mode, the folding hotkey relates to the first line of the codecell.
%%writefile magic command in regular Python I just read what this does. It writes the contents of a Jupyter Cell to the specified file.
Find your configuration directory via jupyter --config-dir
(mine is ~/.jupyter
). Then edit or create nbconfig/notebook.json
to add 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.)
Restart Jupyter and reload your notebook.
Source: https://github.com/jupyter/notebook/issues/106
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With