User to user discussion and support for UltraEdit, UEStudio, UltraCompare, and other IDM applications.

Syntax highlighting, code folding, brace matching, code indenting, and function list
2 posts Page 1 of 1
Is there a way to have two template xml file associated to a syntax wordfile?

For example I have a csharp xml template that is used with csharp wordfile. What I'd like to do is associate another csharp2 template file to the csharp wordfile. Essentially I'd like to split out my templates for a given language. I see there is a option to use ALL the template files (snip) below, but I'd like to be more selective.


Show all language templates in Template List
If this option is selected, all language templates will be accessible in the Template List regardless of the type of file currently loaded for editing.
As explained at Smart templates management there are 4 types of smart templates:

  • global templates
  • layout (environment) templates
  • language templates
  • project templates
How to best manage two template files for C# depends on your use case which was unfortunately not described by you.

1. C# project template

Let's say you want standard C# templates which are defined as language template and stored in templates\language\csharp-tpl.xml. And you want specific for a project another C# template file with name project-name-tpl.xml stored in the projects directory, or a subdirectory of the projects directory, or in templates\language or whatever you think is a good location for the project templates file. Then you open the project settings dialog and configure there this project specific C# template as project template. If the project with this project specific C# template file is not opened, the additional set of C# templates are also not available.

2. C# layout template

Another option would be putting the second set of C# templates into a layout (environment) template file stored in templates\environment\layout-name.tp1. It can be selected if second set of C# templates are available in addition to standard C# language templates by switching the layout via View - Layouts. The second layout can be a simple copy of the used standard layout with the only difference of having C# templates defined which standard layout does not have. All other layout settings like menus, toolbars, and workspace layout are identical.

3. Second C# wordfile with second C# language template

It is not possible to assign 2 language templates to 1 syntax highlighting wordfile.

But it is possible to create a copy of csharp.uew with a different file name and a slightly different language name in first line of the wordfile. If there is no other difference than language name between the two wordfiles, the default syntax highlighting language for a C# file is more or less selected by UltraEdit randomly or perhaps according to name of language (never tried that) because of identical file extensions list in both wordfiles. Perhaps it would be better to use in second C# wordfile a different list of file extensions or an empty file extensions list (never automatically applied to a file) or a file names instead of file extensions list to avoid concurrent wordfiles for same type of files.

Which syntax highlighting is active for active C# file can be controlled via View - View as (Highlighting File Type) or by clicking on language selector list in the status bar (not available on usage of basic status bar). With switching the syntax highlighting language, the appropriate templates are loaded and the others are unloaded.

Of course the configuration setting Show all language templates in Template List can be used in this use case to have both templates for C# active at the same time.

Note: It is also possible to configure a project specific wordfile for a project.
Best regards from Austria
2 posts Page 1 of 1