Development Tools
notepad
How to Create a User Defined Language in Notepad ? (Custom Syntax Highlighting)
How to Create a User Defined Language in Notepad ? (Custom Syntax Highlighting)
In Notepad, the "Define User Language" dialog box is located at the bottom of the "Language" menu. You need to set the document to "None" language format before it can be enabled.

Where to open the "Define User Language" dialog box
Notepad’s custom syntax highlighting feature is buried a bit deep, not in the Settings menu or in a plug-in—it hangs directly at the bottom of语言menu. You must first ensure that the current document is plain text (such as creating a new empty file, or using Ctrl N ), otherwise the menu item will be grayed out. Click on语言→ 定义你的语言… to enter the editing interface; if you do not see this item, it means that your current document has been associated with a certain language (for example, you are editing a .py file), first switch to语言→ 语言格式→ 无and try again.
How to write the simplest usable UDL rules (taking JSON style as an example)
UDL does not support regular capture groups or nested scopes, and the rules are a flat "keyword → style" mapping. If you want to highlight literals such as true , false , and null , just fill in column关键字列表1 , one per line, without quotation marks or spaces. Don't try to write true|false - UDL will treat it as a word; and don't add \b , it doesn't recognize regular metacharacters at all.
Common error phenomenon: true is also marked blue in the string (for example, "value": true true is normal, but true in "status": "true" is also marked incorrectly). This is because UDL is not context aware - it cannot distinguish between literal and string content. There are only two solutions: either accept this limitation, or switch to an editor that supports TextMate syntax (such as VS Code).
- Fill in
扩展名fieldjsonormyconf, separate multiple entries with spaces (not commas) -
注释type selects行内注释or块注释, which determines whether注释开启and注释结束settings you set will take effect. - The font color can be adjusted in
样式标记器tab. After changing, you have to manually click保存为…to actually writeuserDefineLang.xml
Why doesn’t the change take effect? Check these three places
UDL does not take effect after modification, 90% of the time it is stuck in these three places:
- No extension is bound to the file: After changing the language, you must save the file with the corresponding suffix (such as
.mycfg), or manually execute语言→ 自定义→ YourLanguageName -
userDefineLang.xmlis locked by Notepad: close all Notepad instances before changing it, otherwise the configuration you saved may be overwritten by the old version in the memory. - Windows permission issues: If Notepad is opened by right-clicking "Run as administrator" and
userDefineLang.xmlis under%PROGRAMFILES%, modifications by ordinary users will be blocked; it is recommended to install the portable version, and the configuration file is in.\plugins\Config\userDefineLang.xml, with no hindrance to reading and writing.
Where are the hard boundaries of UDL?
It cannot handle state machine logic that requires lexical analysis: such as Python's indentation sensitivity, JavaScript's template string nesting, and YAML's indentation level. In these scenarios,关键字and分隔符rules frequently fight. Don't expect it to support theme color linkage - the colors written in userDefineLang.xml are absolute values. After changing to a dark theme, the color will not be automatically inverted. You have to manually adjust前景色/背景色.
If you really want to maintain the highlighting of a new language for a long time, it is better to export the UDL to XML, and then use a script to batch generate TextMate .tmLanguage ; Notepad itself is only suitable for lightweight, static vocabulary annotation - such as fixed field names, status codes, and protocol headers in the company's internal configuration files.
The above is the detailed content of How to Create a User Defined Language in Notepad ? (Custom Syntax Highlighting). For more information, please follow other related articles on the PHP Chinese website!
Hot AI Tools
Undress AI Tool
Undress images for free
AI Clothes Remover
Online AI tool for removing clothes from photos.
Undresser.AI Undress
AI-powered app for creating realistic nude photos
ArtGPT
AI image generator for creative art from text prompts.
Stock Market GPT
AI powered investment research for smarter decisions
Hot Article
Popular tool
Notepad++7.3.1
Easy-to-use and free code editor
SublimeText3 Chinese version
Chinese version, very easy to use
Zend Studio 13.0.1
Powerful PHP integrated development environment
Dreamweaver CS6
Visual web development tools
SublimeText3 Mac version
God-level code editing software (SublimeText3)
Hot Topics
20570
7
13669
4




