Skip to content

Instantly share code, notes, and snippets.

@archatas
Created February 6, 2017 22:06
Show Gist options
  • Save archatas/10ccccbf11bc4616c933168c31154488 to your computer and use it in GitHub Desktop.
Save archatas/10ccccbf11bc4616c933168c31154488 to your computer and use it in GitHub Desktop.
Instructions how to configure nano for more user friendliness

Why nano?

Nano is a simple and intuitive editor preinstalled on many Unix-based computers. All the necessary keyboard shortcuts are presented all the time in the footer of this program, so you don't get lost when you need to edit a file in the shell.

Make sure that you have syntax highlighting configuration files

Check for \*.nanorc files at one of the following directories:

  • /usr/share/nano/*.nanorc - for Linux
  • /fbsd/usr/iports/share/nano/*.nanorc - for FreeBSD
  • /usr/local/share/nano/*.nanorc - for Mac OS X

If you are using a Mac and the mentioned files don't exist there, run the following:

$ brew tap homebrew/dupes
$ brew install nano

Edit nano configuration

Decide whether you want to do changes for all users or just for the current user:

  • If you want to configure nano globally for all users, edit or create a file /etc/nanorc.
  • If you want to configure nano for the current user, edit or create a file ~/.nanorc.

Add the following lines there:

set nowrap
include "/usr/local/share/nano/*.nanorc"

The first line disables automatic word wrapping for long lines (that is very annoying for files like Python scripts or Apache configuration). The second line enables syntax highlighting for all different formats.

Make nano the default editor for the shell

Decide whether you want to do changes for all users or just for the current user:

  • If you want to make nano the default editor globally for all users, edit or create a file /etc/profile.
  • If you want to make nano the default editor for the current user, edit or create a file ~/.profile.

Add the following line there:

export EDITOR=nano

Now nano is the default editor in the shell.

@AndrewDDavis
Copy link

If you run nano from homebrew, it expects the system file in /usr/local/etc/nanorc. May want to suggest a symlink to /etc/nanorc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment