And now, let’s look at the .nanorc file.
Here, i’ll go through the .nanorc config file, try to explain parts of it and set the syntax highlight on.
See the first part for shortcuts .
You can use the sample nanorc from /usr/share/nano/ , a copy from /etc/nanorc, or even from the sample nanorc in /usr/share/doc/nano/examples/. A blank one is just fine too.
If in doubt, do
nano -V to see if it was compiled with the proper flags. here’s mine:
GNU nano version 2.0.4 (compiled 12:23:22, Jun 22 2007)
Email: email@example.com Web: http://www.nano-editor.org/
Compiled options: –disable-wrapping-as-root –enable-color –enable-multibuffer –enable-nanorc –enable-utf8
auto indent: (Meta-I) to toggle
so the next line starts after the same number of spaces /tabs as the previous line.
nano doesn’t know how to properly indent code lines.
set brackets ""')>]}"
to be able to justify paragraphs after one of those characters.
Use ctrl+j to justify the paragraph, meta+j to justify all the file, and ctrl+u to undo the justification
set matchbrackets "(]}"
use meta+altgr+9 (i.e meta+] ) to switch between the matching brackets
Remove empty first line (Meta-O) to toggle
as said in the manual: “Use the blank line below the titlebar as extra editing space.”
Hide the help shortcuts at the bottom ( Meta-X )
“Don’t display the help lists at the bottom of the screen.”
Mouse support (Meta-M)
Well, i’m still giving a 2nd change, because it’s not that useful. With it enable, nano will allow you to move the cursor, set a mark (see below) and use the helpful shortcut list at the bottom. To use the mark, double click and drag, or double click and move the cursor with the arrow keys. You can them, cut ( ctrl+k ), and to paste it, ctrl+u. Those are the good things. the bad, it won’t let you middle click and thus paste things into the current position inside the editor. Also, copying text with the mouse to use outside the editor is disabled. So basicly, we get a more featured editor, but with less integration with the surrounding environment. Completely useless in text mode.
If only it had the ability to scroll up/down with the mouse wheel…
Allow multibuffer (Meta-F)
This is actually extremely useful. If this option isn’t active, the crtl+r (read file)
just adds the file into the same buffer. With it, it opens a new buffer! You can cicle through the buffers with Meta+< and Meta+>
Text will scroll line-by-line, instead of the usual chunk-by-chunk behaviour.
Save automatically on exit (without prompt)
Although this might seen a time-saver, beware to not enable this on a normal user. When enabled, if nano opens a file which the user doesn’t have permission and modifies it, nano won’t ask for the option to not save it, and thus you’ll be stuck inside nano forever! :P
( you can ofc, save it on a proper directory:/home/you/thatevilfile )
Aparently, the bug is said to be fixed on the version2, but i guess not quite. i’ve to check upon that…
Next the include files for the syntax highlighting. just comment the include lines you’ll think wont be useful.
i’m using this ones:
## Nanorc files
## Patch files
## Bourne shell scripts
## Syntax Highlight Pack
## makefile .am
I’ve took the following 2 from
more Syntax highlighting(dead link as of 2012)
This is useful for those debian people.
## syntax highlighting for /etc/apt/sources.list
## syntax "apt/sources.list" "sources\.list(\.old|~)?$"
color brightmagenta "^deb(-src)? ((http|file|ftp):/[^ ]+|cdrom:\[[^\]]+\]/|cdrom:\[[a-zA-Z0-9\._-\(\) ]+\]/) [^ ]+ .+$"
color brightred "^deb(-src)? ((http|file|ftp):/[^ ]+|cdrom:\[[^\]]+\]/|cdrom:\[[a-zA-Z0-9\._-\(\) ]+\]/) [^ ]+"
color brightgreen "(http|file|ftp):/[^ ]+"
# [^\]] does not work...
color brightgreen "cdrom:\[[a-zA-Z0-9\._-\(\) ]+\]/"
# deb / deb-src
color cyan "^deb"
color brightblue "^deb-src"
color brightyellow "#.*"
config files (.ini)
# ini highlighting
syntax "ini" "\.ini(\.old|~)?$"
color brightred "=.*$"
# equal sign
color green "="
color brightblue "-?[0-9\.]+\s*($|;)"
color brightmagenta "ON|OFF|On|Off|on|off\s*($|;)"
color brightcyan "^\s*\[.*\]"
color cyan "^\s*[a-zA-Z0-9_\.]+"
color brightyellow ";.*$"
That’s all for now.. Hope you’ll find it useful to bring more “shiningness” to your nano.