To see the word wrapping style you described, use nano’s “soft wrapping”: Esc+$.
The Esc+L command you (and everyone) tried does “hard wrapping.”
Note on keystroke notation – if you are new to Linux, the notation Esc+$ means press and release Esc and then press $. The full key press sequence then is Esc, Shift+4.
(It does not mean hold down escape while pressing $.)
Source: https://www.nano-editor.org/dist/v2.9/nano.html (search for –softwrap)
Note on softwrap and formatting mistakes – If you are new to nano, be a little careful of softwrap. If you are editing a configuration file or something else that is sensitive to newlines or indents, formatting mistakes can be made. Until you get comfortable with softwrap’s behaviors, I suggest doing a quick check with softwrap off (do the key sequence again) before saving.
Note on the goodness provided by others in their answers below – because different operating systems and different versions of nano do things a little differently:
- If you like softwrap on all of the time, set it in your .nanorc, as described in x0a’s answer below, as it is a bit more through than Prashant’s.
- If you have a Raspberry Pi, note chainsawmascara’s answer about needing an extra keystroke for softwrap to go into effect.
- If you have a Mac, like lodeOfCode’s answer below, you can always update nano and here, and thus bask in the warm glow of softwrap!
I’m reading the replies here and need to set this straight!
Nano supports two different forms of line wrapping, and it can be essential to know the difference!
First, the Meta key below is often the Alt key, but not necessarily.
- Soft line wrapping is activated with Meta–$. Wraps lines without inserting line break characters into the file. That is, the effect is purely visual.
- Hard line wrapping is activated with Meta–L. Wraps lines by inserting line breaks into the file. The file is physically changed.
So if you activate it in a file where wraps are meaningful (configuration files, programming languages, scripts), you basically never want the hard line wraps or it’ll change the meaning of the code.
Also, you’d have found these shortcuts with ^G (i.e. Ctrl–G) in Nano.
Just searched for nano line wrapping and this came high in results, so I’ll post my findings for GNU nano 2.2.6 on the Raspberry Pi, Raspbian GNU/Linux 7: Esc+L gave me the same message; but for the line wrapping to take effect I had to modify the line. As soon as I typed another character on the long line, wrapping kicked in.