Syntax Highlighting Customization

New syntax highlighting modes can be added and existing ones overridden using user defined xml files. This document will describe how add new modes and how to override existing ones using the Editra Xml interface.


  • Editra > 0.5.05

Currently this interface only supports using builtin Scintilla lexers, future versions will allow for custom lexers as well.


<!-- Editra XML Interface Specification -->
<!-- Editra Xml can be used to customize or add new syntax highlighting -->
<!-- Opening tag
version attribute used to tell Editra the file has changed since last load
<editra version="1">
   <!-- Specifies a syntax module and lexer
   lang attribute specifies the filetypes name
   lexer attribute specifies the scintilla lexer to use
   <syntax language="Python" lexer="STC_LEX_PYTHON" id="ID_LANG_MYPYTHON">
      <!-- File Extension Associations. Value is just a space separated
             list of file extensions. No Dots.
      <associations value="py pyw"/>
      <!-- KeywordList must be a child of syntax it specifies the keywords
      used by the language.
         <!-- Keywords hold the actual keyword data in character data
         value attribute specifies the keyword sets id/index.
         <keywords value="0">
             if else elif for while in
         <keywords value="1">
             str len setattr getattr
      <!-- SyntaxSpecList must be a child of syntax and it specifies how the
      text is to be styled. For built in lexers the value attribute should be
      a constant used for the set lexer. For custom lexers it should be an
      integer that specifies the custom style id. The tag attribute specifies
      the style used by Editra's internal styling system to highlight the text
         <syntaxspec value="STC_P_DEFAULT" tag="default_style"/>
         <syntaxspec value="STC_P_WORD" tag="keyword_style"/>
      <!-- PropertyList specifies additional properties for folding --> 
         <property value="fold" enable="1"/>
         <property value="tab.timmy.whinge.level" enable="1"/>
      <!-- Specifies the comment pattern
      value attribute should be a space separated list of characters that make
      up the pattern for the comment.
      <commentpattern value="#"/>
      <!-- FeatureList is used to specify extension features to override
      builtin functionality.
      method attribute is used to specify the name of the method that has
      an implementation available.
      source attribute specifies the relative path to where the implementation
      can be found
      Current Method features that can be implemented
      AutoIndenter: AutoIndenter(stc, pos, ichar)
      StyleText: StyleText(stc, start, end)
         <feature method="AutoIndenter" source=""/>
         <!-- <feature method="StyleText" source=""/> -->

Syntax extension files such as the example file above should be placed in the configuration cache directory with the .edxml extension.

Configuration Locations

  • Linux ~/.Editra/cache
  • OSX ~/Library/Application Data/Editra/cache
  • Windows Documents and Settings/USERNAME/Application Data/Editra/cache