August 27, 2013 · bash coding debian hacks learnpython learnshell nano programming raspberrypi textediting tricks

Configuring Nano

GNU Nano is a lightweight text editor which can be found in most Unix-like environments. It is much easier to use than vi (unless you are from the vim-galaxy), not completely feature bloated like emacs and usually does what you need. Out of the box it works like a sort of terminal equivalent of "notepad" on Windows.

However, it has some configuration options which are normally overlooked. It supports syntax highlighting, automatic backups, autoindent, using spaces instead of tabs etc. To edit it's configuration, type in terminal either:

sudo nano /etc/nanorc

or

nano ~/.nanorc

Here is my ~/.nanorc form my Raspberry Pi:

## Use auto-indentation. 
set autoindent 
## Backup files to filename
~. set backup 
## Constantly display the cursor position in the statusbar. Note that 
## this overrides 'quickblank'. 
set const 
## Use cut to end of line by default. 
set cut 
## Set the line length for wrapping text and justifying paragraphs. 
## If fill is 0 or less, the line length will be the screen width less 
## this number. 
set fill 70 
## Don't convert files from DOS/Mac format. 
set noconvert 
## Don't add newlines to the ends of files. 
set nonewlines 
## Do extended regular expression searches by default. 
set regexp 
## Make the Home key smarter. When Home is pressed anywhere but at the 
## very beginning of non-whitespace characters on a line, the cursor 
## will jump to that beginning (either forwards or backwards). If the 
## cursor is already at that position, it will jump to the true 
## beginning of the line. 
set smarthome 
## Use smooth scrolling as the default. 
set smooth 
## Use this spelling checker instead of the internal one. This option 
## does not properly have a default value. 
set speller 'aspell -c' 
## Allow nano to be suspended. 
set suspend 
## Use this tab size instead of the default; it must be greater than 0. 
set tabsize 4 
## Convert typed tabs to spaces. 
set tabstospaces 
include '/usr/share/nano/nanorc.nanorc' 
include '/usr/share/nano/c.nanorc' 
include '/usr/share/nano/css.nanorc' 
include '/usr/share/nano/debian.nanorc' 
include '/usr/share/nano/gentoo.nanorc' 
include '/usr/share/nano/html.nanorc' 
include '/usr/share/nano/php.nanorc' 
include '/usr/share/nano/tcl.nanorc' 
include '/usr/share/nano/tex.nanorc' 
include '/usr/share/nano/mutt.nanorc' 
include '/usr/share/nano/patch.nanorc' 
include '/usr/share/nano/man.nanorc' 
include '/usr/share/nano/groff.nanorc'
include '/usr/share/nano/perl.nanorc' 
include '/usr/share/nano/python.nanorc' 
include '/usr/share/nano/ruby.nanorc' 
include '/usr/share/nano/java.nanorc' 
include '/usr/share/nano/awk.nanorc' 
include '/usr/share/nano/asm.nanorc' 
include '/usr/share/nano/sh.nanorc' 
include '/usr/share/nano/pov.nanorc' 
include '/usr/share/nano/xml.nanorc'
  • LinkedIn
  • Tumblr
  • Reddit
  • Google+
  • Pinterest
  • Pocket

Contact