Package: nano
Version: 2.0.7-4

[Summary: please change the nano default so that it does not hard-wrap lines by default, whether or not it is running as root.]

nano is the default text editor on Debian, and for good reason. It provides a friendly interface to new users, while it is lightweight enough to be suitable for a variety of quick tasks, even among power users who forgot how to use vi and don’t want to wait for Emacs to load. But nano comes with a single broken default setting that I need to override in order for it to be useful for most of these tasks: it automatically hard-wraps long lines to the width of the screen by inserting newline characters.

This default is inherited from the editor pico, which is the basis for nano’s UI. pico is part of the PINE (now Alpine) email client, where wrapping makes some amount of sense. But if I’m editing anything other than paragraphs of text, these newlines are annoying at best, and likely to corrupt the syntax of my file at worst.

In an attempt to address this issue, Debian patches nano and configures it with the --disable-wrapping-as-root option, on the theory that wrapping is most likely to corrupt files you might commonly edit as root (#135978). But in my experience (which I’m sure is not unique), those same considerations also apply to most files one would commonly edit as a normal user. Many programs that you can configure in /etc/foo as root can also be configured in ~/.foo by a normal user, to say nothing of any other non-mail text files that the user wants to work on.

It is, while annoying, not too difficult to train oneself to use the nano -w flag all the time to disable wrapping. However, Debian uses nano as the defult editor (through the sensible-editor mechanism that ends up looking at /etc/alternatives/editor -> /usr/bin/nano) for many operations where there is no opportunity to pass flags directly to the editor.

For example, sudo -e allows the user to edit a file with root permissions by invoking their editor _as themself_ on a temporary buffer. Even though you can use sudo -e to edit any file that could be accessed by running nano as root (which would disable wrapping), the nano invoked by sudo -e will use wrapping by default. Other examples that come to mind include crontab -e (LP #261495), and many VCS commands, a particularly nasty case being git rebase --interactive.

Thus the user, if they have not already moved on to a different $EDITOR by this point, has no choice but to figure out how to disable wrapping in nano by default. They eventually learn that they need to turn on “set nowrap” in their ~/.nanorc or /etc/nanorc. This is an acceptable solution for them, until they log into a different Debian or Ubuntu system and find that they need to reconfigure nano again.

If everyone has to change the default setting to get a useful editor, then the default is wrong and should be changed in Debian. Either nano should be configured with --disable-wrapping instead of --disable-wrapping-as-root, or the Debian default /etc/nanorc should have “set nowrap” uncommented.

(The latter solution has the advantage that the user could “unset nowrap” in their ~/.nanorc if they so desired. Though I have a hard time imagining why anyone finds this behavior useful, especially when ^J can already be used to wrap a paragraph as needed.)

Reply via email to