# User Defined Languages

User defined languages allow you to add your own language to Notepad++. This is a very quick and easy way to do so.

The NpWiki++ page about user defined language files lists all known such languages and allows sharing new contributed files.

Notepad++ always has the main User Defined language available. You can use this to test your settings and then later on create a new language based on this. The User Defined language gets reset each time you restart Notepad++, its settings will not be saved. User defined languages are available from the bottom of the language menu.

To define one, you need the User Defined Dialog, which can be accessed by selecting Language->User Define Dialog... or pressing the button.

The dialog can float like any regular dialog when open, or be docked in the main Notepad++ window. Simply click Dock/Undock to do so. If the dialog is undocked (floating) you can control its transparency. Enable the transparency checkbox and control the amount using the slider. Note that transparency is only available on Windows 2000 and later.

The dialog shows a dropdown list of the currently defined user languages. Select one to change its parameters, if possible they will be automatically saved. To create a new user language based on the current state of the main User Defined language, click the Create New... button, a dialog will pop up asking for the name. To create a new User language based on the currently selected language, click Save As... and enter the new name. If you have selected a user created language, you can click on the Rename button to enter a new name if necessary, and the Remove button will delete the language.

Note that built-in languages may have various peculiarities which prevent them to be represented as user defined language, let alone be modified through this venue.

If you want the user language to ignore the case of the text (so it will be case insensitive when looking for keywords), enable the ignore case checkbox.

For user created languages, you can also define what file extensions to associate with them for language autodetection in the textbox with the Ext label.

Most settings have a certain text style associated with them. These work the same as in the Styler Configurator (see Styler Configurator for details).

Other aspects of the language are controlled by the settings divided into four groups. Please be sure to read the detailed tutorial at the developer's site for a detailed account.

### Default style and Folding (Folder & Default tab)

This tab controls the style of the default text (text that has no special attributes or meaning) and the keywords that control the folding, as well as some more advanced folding options. A keyword in either Folder Open group will trigger a new fold group that can be expanded and collapsed. A keyword in the corresponding Folder Close group will close any opened group.

### Keywords (Keywords Lists tab)

This tab controls what keywords are registered with the language. You can define up to eight groups of keywords, each with its own style. If you enable the Prefix option for a group, that means that these keywords can be prefixes of entire words, and thus will be detected even if the keyword is directly followed by other text. In that case the other text will be styled the same as the keyword. Using multiple words as a single keyword (like "end if") is supported, please see the tutorial for some more details.

### Comments/Numbers (Comment & Number tab)

This tab controls the behavior and appearance of comments, and the appearance of numbers. You can define multiple comment symbols that are comment line symbols. These comments run from the symbol itself to the end of the line. You can also define comment block symbols. These symbols start commenting from any comment open symbol, until and comment close symbol is reached.

Comments allow nested styles. This not only enables (if you so choose) nested comments, but also permits the styling of keywords or strings inside comments.

Basically, numbers are only recognized if they start a word with characters ranging from 0-9, where only the number symbols are styled as such. However, numbers can optionally be preceded or followed by special characters (like "0x", "€" and the like). For numbers with a prefix, extra characters are allowed inside the number. This is how you'd set 'a' to 'f' as hexadecimal digits and get proper styling of the whole number). Range symbols between numbers are supported as well.

### Operators and Delimiters tab

This tab controls what operator symbols exist and what symbols act as delimiters. Operator symbols are characters that split two words. They behave much as whitespace but can be styled differently.

Some languages may use words as operators, like "and" instead of "&&". The second operator group is meant to collect them. Both sorts of operators are styled the same. The tutorial will hint at some creative uses for them.

Delimiters are single characters and usually defined in pairs. Any text between a pair of delimiters is styled as such. A good example is a string, which is delimited on both sides with double quotes and drawn in a different color. Since, in many languages, a string may contain the string delimiter with a special prefix, you can enable and choose this prefix, the escape character. Each of the 8 delimiter groups allows optional nesting of style, just like comments do.

## Storing and sharing user defined language definitions

Basically, the settings for all user defined languages are stored in a configuration file called `userDefineLang.xml`. This is handy when you have defined only one language, or when you want to share all of the languages you defined. Because this scheme is too coarse grained at times, you can also

- Import a language from an external file, as long as it has proper contents. Changes will be saved in your file for all languages.
- Export an individual language to an .xml file.

Note that the Save As button does not create any new file. It duplicates the current language using a new name you supply. Export does create a new file. Likewise, Create New creates a new language with all attributes reset to default and the name you provide.

Please also note that, if you import a language you already have, you will get duplicate entries in the language list and in the language menu.