Howto:Syntax highlighting for Nasal

From FlightGear wiki
Revision as of 11:30, 12 February 2012 by Hooray (talk | contribs) (http://flightgear.org/forums/viewtopic.php?f=30&t=12495#p128116)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Vim

There's Nasal syntax-highlighting support available for some editors, which is a big advantage, as it makes Nasal coding much easier. It can often point to syntax errors and so reduce the number of tedious time-consuming and unproductive FlightGear runs.

It also makes understanding other people's code easier. One such editor is the free vim or its gui variant gvim.

It's not for everyone but it's free, and testing it doesn't hurt: http://www.vim.org/.

The syntax definition file comes with the FlightGear code (http://gitorious.org/fg/flightgear/blobs/next/scripts/syntax/nasal.vim). Highlighting works even for Nasal embedded in XML files (type ":set ft=nasal", where ft stands for file-type)

Here's an example, which demonstrates a short code segment with three syntax errors as well as the highlighting of a matching pair of parentheses (yellow) and trailing spaces (blue x). (The leading blue dots aren't on by default. They help to spot tab crimes.)

Screen shot illustrating syntax highlighting in Vim