|


| NAVIGATION |
|
Home |
|
Store |
|
|
| INSIDE MAC |
|
Television Shows |
|
Broadcast Shows |
|
Daily News Shows |
|
Special Shows |
|
|
| EVENTS |
|
|
|
|
|
|
|
|
| DAILY TIPS |
|
Design |
|
Mac OS X |
|
Mac OS X UNIX |
|
|
| COMMUNITY |
|
Forums |
|
Surveys |
|
|
| NEWS |
|
Current |
|
Press |
|
Archive |
|
|
| FEATURES |
|
Editorial |
|
Dr. Mac |
|
Reviews |
|
Reader Reports |
|
|
| RESOURCES |
|
FAQ |
|
Documentation |
|
Learning Center |
|
MAN pages |
|
Glossary |
|
Tutorials |
|
Tips |
|
Links |
|
|
|

|
|
|
OSXFAQ Mac OS X UNIX Tip-of-the-Day

Week 106 - New in Tiger (2 January 2006)
by
Adrian Mayo - Editor, OSXFAQ
Wednesday - Syntax Colour in Nano
Nano is capable of syntax highlighting. For example, we can tell it to display HTML tags such as <head> in blue, and escaped characters such as & in red. Enter the following into the nanorc file, called .nanorc in your home directory.
#HTML Syntax Highlighting
syntax "HTML" "\.html$"
color blue start="<" end=">"
color red "&[^; ]*;"
The second line says that the HTML syntax is applied to all files who's name ends with .html. The third says that everything between < and > (possibly across multiple lines) is to be coloured blue, and the fourth says that everything between & and ; (when they are not separated by white space or semicolon) is to be colored red. (The text between [ and ] includes a space character and a tab characters.)
You may specify any of the colors: white, black, red, blue, green, yellow, magenta, cyan; and prefix any with the word bright. The string to match-and-color is specified using an extended regular expression.
Try loading an HTML file into a new instance of nano, such as ~/Sites/index.html, and you should see the syntax highlighting described above in action.
Download the nano source files (see yesterday's tip) and you'll find a file called nanorc.sample. This file gives examples of what can be placed in the configuration file, and how to write syntax highlighting instructions.
Visit the Site of the Book of the Unix Tips:
Project 30 covers nano configuration.
Projects 77 and 78 teach regular expressions.
Discuss this trick in the
Learning Center forum
|





|
 |
|
 |
Copyright © 2000-2008 Inside Mac Media, Inc. All rights reserved. |
Apple assumes no responsibility with regard to the selection, performance, or use of the products or services. All understandings, agreements, or warranties, if any, take place directly between the vendors and prospective users. |
| Apple, the Apple logo, Mac, PowerMac G4, PowerMac G5, Xserve, Xserve RAID, PowerBook, iBook, Airport, AirPort Extreme, iMac, eMac, iLife, iMovie, iCal, iPhoto, iTunes, QuickTime, FireWire, iPod, iSight, AppleWorks, Macintosh, Jaguar, Panther, Mac OS, Mac OS X and Mac OS X Server are trademarks of Apple Computer, Inc. |
|