Syntax highlighting tends to be language specific. However, if you want to do it for all files, you can simply create a very very simple language definition. I took the Perl syntax style (which treats lines starting with #
as comments) from /usr/share/nano/perl.nanorc
and adapted it to:
syntax "All" "."
color green "^\s*#.*"
As far as I can tell, the nano syntax highlight format needs at least one test to define the file type, and then you can set filters for the color. So, I used the most simple test I can think of, that the file's name contains at least one character, and I named this syntax style All
:
syntax "All" "."
I then told it to color lines starting with 0 or more spaces and then a #
in green:
color green "^\s*#.*"
So, if you create a file called $HOME/.nanorc
and paste those two lines into it, your comments will be highlighted in green.