Disable text wrapping in nano

Word wrapping in nano text editor can make scripts and files fail to run/parse properly. A simple edit can goof up a config or script by adding unwanted newlines. These settings are in general good for nano on any operating system.

Disable text wrap in nano by adding to ~/.nanorc

set nowrap

A suggested ~/.nanorc contains the following for good defaults including Python coding:

set constantshow
set tabsize 4
set nowrap
set tabstospaces
  • constantshow: show line and column of cursor position (on old nano version as in Red Hat 7, this option may not be recognized)
  • tabsize 4, tabstospaces: make tabs into 4 spaces
  • nowrap: disable long-line text wrapping

Nano syntax highlighting is enabled with include statements in ~/.nanorc.