ini Syndicate content

» Syntax Highlighting in Nano

Tue, 04/10/2007 - 17:14

When I’m messing around with config files on the command line my editor of choice is Nano. It’s simple, fast and pretty much straight forward. You don’t have to learn any commands and can use keyboard shortcuts just like in GUI programs.


Today I had a look on the project website and saw that there are tons of settings which I really missed before. Just have a look into your /etc/nanorc for a default config file with all settings and their default values. Here are those I like most:

  • smooth (scrolling)
  • autoindent
  • mouse (though I use it rarely)
  • smarthome
  • tabsize (8 is far to much, I love 4)
Syntax Highlighting

Yes! Nano supports syntax highlighting! And I never knew it, but heck - it’s never to late. Not for neat features like this one, though I really wonder why this is not activated by default…

In the aforementioned /etc/nanorc are already some default languages which just wait to be commented out. You might also want to have a look into /usr/share/nano, there are some languages you can include in your nanorc file with:

include “/usr/share/nano/html.nanorc”

Additionally I found some more languages on the gentoo wiki. And of course I’ll post any homebrew syntax files in my Snippets section.

my syntax highlighting files

» syntax highlighting for *.ini files in nano

Tue, 04/10/2007 - 17:01

Use the snippet below in your ~/.nanorc or /etc/nanorc file to highlight *.ini files like php.ini in Nano.

  1. # ini highlighting
  2. syntax "ini" "\.ini(\.old|~)?$"
  4. # values
  5. color brightred "=.*$"
  6. # equal sign
  7. color green "="
  8. # numbers
  9. color brightblue "-?[0-9\.]+\s*($|;)"
  10. # ON/OFF
  11. color brightmagenta "ON|OFF|On|Off|on|off\s*($|;)"
  12. # sections
  13. color brightcyan "^\s*\[.*\]"
  14. # keys
  15. color cyan "^\s*[a-zA-Z0-9_\.]+"
  16. # comments
  17. color brightyellow ";.*$"