Search code examples
syntax-highlightingjedit

jEdit: How to turn on syntax highlight for a given extension?


I want .xslt files to be highlighted as XML in jEdit.

How to do it in jEdit?


Solution

  • There are different possible solutions according to what you want.
    Besides that, there is an xsl mode that you might prefer for .xslt files over the xml mode. That mode is also the default for .xsl files which is the standard extension for XSL(T) scripts.
    But as you asked for xml, I'll keep with that in the following descriptions.

    • If your .xslt file starts with an XML header like <?xml version="1.0" ?> (actually the important part is the <?xml in the beginning), your file is automatically highlighted with the xml mode, independent of its name

    • If you want to highlight the currently viewed file with a specific mode as long as it stays in the recent files list, just change the mode in the buffer settings, reachable through double click in the status bar on (<mode>,<wrap>,<encoding>) or via Utilities -> Buffer Settings...

    • If you want to highlight a file always with a specific mode, no matter in which jEdit you open it, embed the mode as buffer-local property in the first or last 10 lines of the file like <!-- :mode=xml: -->

    • If you want to highlight all files that end with .xslt with the xml mode, you need to edit your mode settings. For this

      • go to Utilities -> Global Options... -> jEdit -> Editing
      • select the xml mode
      • uncheck Use default settings
      • edit the File name glob to also match .xslt files