Disable text wrapping in nano

Word wrapping in nano text editor can make scripts and files fail to run/parse properly. This is especially a problem with nano in Cygwin, where 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

add to ~/.nanorc

set nowrap

general nano setup

In general on any operating system, a suggested ~/.nanorc contains the following for good defaults including Python coding:

set constantshow
set tabsize 4
set nowrap
set tabstospaces

These lines:

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

syntax highlighting

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