Skip to content

Notepad++ User-Defined Language

The User-Defined Language feature in Notepad++ allows users to create custom syntax highlighting rules for specific file types that are not supported by default.^[600-developer__tools__nginx-notepad-color__nginx-notepad-color.md]

A user-defined language is configured using an XML file that imports directly into the application.^[600-developer__tools__nginx-notepad-color__nginx-notepad-color.md] This XML file defines the language's name, file extensions, and specific syntax behaviors such as keywords, operators, delimiters, and comments.^[600-developer__tools__nginx-notepad-color__nginx-notepad-color.md]

Configuration Structure

The definition is encapsulated within a root <NotepadPlus> element containing a single <UserLang> node.^[600-developer__tools__nginx-notepad-color__nginx-notepad-color.md] Key attributes include:

  • name: The identifier for the language (e.g., "Nginx").
  • ext: The file extension associated with the language (e.g., "conf").

Settings and Syntax

Global syntax behavior is controlled within the <Settings> tag.^[600-developer__tools__nginx-notepad-color__nginx-notepad-color.md] Options include: * Case Sensitivity: The caseIgnored attribute determines if keywords are case-sensitive. * Symbol Handling: The <TreatAsSymbol> element configures whether symbols are treated as operators or standard identifiers. * Prefixes: The <Prefix> element allows specific word lists to function as prefixes for other terms.

Keyword Lists

Syntax elements are categorized into numbered lists within the <KeywordLists> section.^[600-developer__tools__nginx-notepad-color__nginx-notepad-color.md] These include:

  • Delimiters: Defines specific boundary characters.
  • Folding: Designates the "Folder+" (open) and "Folder-" (close) characters used for code folding (e.g., { and }).
  • Operators: Specifies characters treated as operators (e.g., *, ;, [, ]).
  • Comments: Defines the format for line and block comments (e.g., 0# for # comments).
  • Words1–Words4: Lists for classifying different types of keywords or directives (e.g., variables, block names like http or server, or specific directives).

Styling

Visual appearance is managed in the <Styles> section, where fgColor (foreground color) and fontStyle (bold, italic) are defined for each syntax category.^[600-developer__tools__nginx-notepad-color__nginx-notepad-color.md] Style IDs correspond to specific elements like keywords, comments, folders, and operators.

  • [[Nginx]]
  • [[Syntax Highlighting]]
  • [[XML]]

Sources

^[600-developer__tools__nginx-notepad-color__nginx-notepad-color.md]