9

My nano did not wrap long lines automatically at first, they just kept going. I do not know what I did but now the automatic wrapping is enabled.

I want to know how to reconfigure nano to disable automatic line wrapping, this has bothered me a lot.

I've seen the nano -w command that it comes without wrapping, but what I want is to disable it by default and run nano without having to worry about wrapping.

piet.t
  • 11,718
  • 21
  • 43
  • 52

2 Answers2

13

To change persistent settings for nano, we can edit the user-specific .nanorc file (/home/user/.nanorc). This file contains configuration settings that nano loads on start-up.

To disable line-wrapping, we need to specify the nowrap directive. Add this line to .nanorc:

set nowrap 

We may need to create this file if it doesn't exist. For more information about the available settings in this file, see the .nanorc man page:

$ man nanorc
Cy Rossignol
  • 16,216
  • 4
  • 57
  • 83
  • 1
    I made a request to change the default or add a warning: https://savannah.gnu.org/bugs/index.php?55067 – mwfearnley Nov 21 '18 at 11:05
  • A brief discussion took place in http://lists.gnu.org/archive/html/nano-devel/2018-11/msg00057.html. People seem generally in favour of having `set nowrap` by default, but no decisions seem to have been made. – mwfearnley Dec 09 '18 at 17:10
  • Good suggestion @mwfearnley. I think some distributions already build nano with `nowrap` and other less-obnoxious defaults. – Cy Rossignol Dec 10 '18 at 16:50
  • FWIW, just `set nowrap` didn't do it for me, but adding `set softwrap` as well did. From [here](https://unix.stackexchange.com/a/464614/81185). – RolfBly Mar 10 '19 at 12:35
  • 1
    None of nowrap/softwrap works. Nano 4.8, Ubuntu 20.04. – Damn Vegetables Nov 18 '20 at 07:59
2

For others like me that hit this question from google and only want to disable wrapping temporarily, press EscL.

That toggles "Hard wrapping of overlong lines".

jpa
  • 10,351
  • 1
  • 28
  • 45