Edit Modes

An edit mode specifies syntax highlighting rules, auto indent behavior, and various other customizations for editing a certain file type. This section only covers using existing edit modes; information about writing your own can be found in Part II, “Writing Edit Modes”.

When a file is opened, jEdit first checks the file name against a list of known patterns. For example, files whose names end with .c are opened with C mode, and files named Makefile are opened with Makefile mode. If a suitable match based on file name cannot be found, jEdit checks the first line of the file. For example, files whose first line is #!/bin/sh are opened with shell script mode.

Mode Selection

File name and first line matching is done using glob patterns similar to those used in Unix shells. Glob patterns associated with edit modes can be changed in the Editing pane of the Utilities> Options dialog box. Note that the glob patterns must match the file name or first line exactly; so to match files whose first line contains begin, you must use a first line glob of *begin*. See Appendix D, Glob Patterns for a description of glob pattern syntax.

The default edit mode for files which do not match any pattern can be set in the Editing pane as well.

The edit mode can be specified manually as well. The current buffer's edit mode can be set on a one-time basis in the Utilities>Buffer Options dialog box; see the section called “The Buffer Options Dialog Box”. To set a buffer's edit mode for future editing sessions, place the following in one of the first or last 10 lines of the buffer, where edit mode is the name of the desired edit mode:

:mode=edit mode:

Syntax Highlighting

Syntax highlighting is the display of programming language tokens using different fonts and colors. This makes code easier to follow and errors such as misplaced quotes easier to spot. All edit modes except for the plain text mode perform some kind of syntax highlighting.

The colors and styles used to highlight syntax tokens can be changed in the Syntax Highlighting pane of the Utilities> Options dialog box; see the section called “The Syntax Highlighting Pane”.