### 3.6 Syntax Highlighting

Syntax highlighting is particularly useful for programming language text or other types of documents which have a strictly defined syntax. Colors indicate different syntactic categories of text according to the syntax definition in use.

Syntax definitions are stored in separate files. `ne` comes with a suite of syntax definitions for many popular programming languages. When you load a file, `ne` selects the appropriate syntax definition as determined by the filename extension in much the same way autoprefs are loaded. It also contains a built-in table of common filename extensions that share the same syntax definitions. For example, both ‘`cbl`’, and ‘`cob`’ files use the ‘`cobol`’ definition. See the Syntax command for the complete list of built-in extension mappings.

If there is no matching syntax definition for the filename extension, or if the buffer you are editing has no filename yet, or you just want to try a different syntax definition, you can load and use the syntax definition of your choice with the `Syntax` command. It takes the syntax name as a parameter. For example, the name “`c`” works for C syntax files with extensions ‘`.c`’, ‘`.h`’, ‘`c++`’, etc. `ne` searches for the specified syntax definition file in the ‘`syntax`’ subdirectory of your `~/.ne` directory first. If not found there, `ne` then looks in the ‘`syntax`’ subdirectory of `ne`'s global directory for the syntax definition file. See Arguments.

With no parameter, the `Syntax` command prompts you for a syntax to load, the offered default being the currently loaded syntax if there is one.

You can create your own syntax definitions and store them in your `~/.ne/syntax` directory (actually, modifying the colors of an existing definition is much easier; see Hints and Tricks). A complete explanation of syntax specifications is beyond the scope of this document, but the existing definition files should prove to be useful examples. In particular, the `syntax/c.jsf` file contains some particularly helpful comments. Syntax definition files have a ‘`.jsf`’ extension. Do not include that extension when using the `Syntax` command.

Syntax highlighting does incur a slight penalty in memory used per line of text, and it also consumes some CPU resources. For small to medium sized files you'll probably never notice. But for extremely large files—on the order of the size of your system's RAM—the difference could be significant. If you invoke `ne` with the `--no-syntax` parameter, `ne` will disable the syntax highlighting mechanism entirely, freeing up the memory and CPU otherwise consumed. (Note that if you are that tight on memory, you may need to disable the undo buffer as well. See DoUndo.)

`ne` uses code from another editor—the GPL-licensed `joe`—for its syntax highlighting capabilities. Because of this fact, the syntax definition files are identical, even to the ‘`.jsf`’ extension, which is an acronym for “Joe's Syntax File”. It's possible that if both `joe` and `ne` are installed on your system that they share the same syntax file directory.