Smart templates management

Smart templates management

2362
MasterMaster
2362

    Mar 03, 2012#1

    Well, UltraEdit for Windows version 18 is at long last out and available.

    I see that they have designed it to where language specific smart templates are in a directory to themselves. This should make it easy to create templates for a specific language, then share them with others.

    They have also provided templates for a number of languages, just as they do for wordfiles. That was very nice of them to give us the head start. I have noticed a couple of errors in PHP templates already, though. Not the implementation of the template system, just wrong format on how a couple of functions were called. They called them without the required parentheses. I'll have to check them more thoroughly when I have time.

    I will definitely need to go through and rename all the templates. I'm trying to decide how it would best organize the ones they have already put in, and how to add additional stuff so as to make it easy to find them again later. I am considering putting keywords in front of the name, as part of the name.

    For example, placing "str" in front of string handling functions, "file" in front of file handling functions, "ctrl" in front of control structures (if, for, foreach, etc.), and so on and so forth. Then, I can put "snip" in front of Code Snippets that can be actual full routines and code that I want inserted into multiple programs for reuse. This will make it easier to locate them, especially since you can search by typing the first few characters of the templates.

    6,688587
    Grand MasterGrand Master
    6,688587

      Mar 13, 2012#2

      Using a short prefix to group the smart templates is definitely a good idea. I would not use a prefix for control structures like if, for, while statements because it would make it more difficult to insert such a very often needed template by simply typing their names.

      On the other hand if multiple templates for one kind of a control structure are defined with different variables and/or different structures, it makes sense to group them with a prefix too. For example there could be a general if and 1 or more additional _ifx. So when a special version of an if should be inserted, just _if can be typed, and with either knowing and typing the suffix or using the auto-completion dialog, the appropriate special version could be called.

      What should be avoided in template names are spaces. UltraEdit v18.00.0.1025 compares currently typed word with the beginning of a template name. A space character is always a word delimiter. Therefore auto-suggestion feature for templates triggered by waiting a short time after entering a word does not work good for templates with a space in name. I recommend a CamelCase naming scheme for smart templates. That avoids also auto-suggestion of templates during normal typing.

      2362
      MasterMaster
      2362

        Mar 13, 2012#3

        CamelCase naming is a great idea for the templates. I shall keep that in mind. I imagine underscores and hyphens will cause the same issues as spaces in many cases, so CamelCase would definitely be the most efficient solution.

        I'll know more about getting them organized once I get to start actually using the Smart Templates. Unfortunately, I'll have to wait for UEStudio to incorporate them before I can actually start using them and not just testing them.

        13
        Basic UserBasic User
        13

          Mar 16, 2012#4

          Has anybody else problems like me with those smart templates? After updating from 17 to V18.00.0.1029 my old templates where gone and I can not save any new ones :( Do I do something wrong?

          Greetings
          FoTo50

          6,688587
          Grand MasterGrand Master
          6,688587

            Mar 16, 2012#5

            Here is a detailed description about template management observed with UE for Windows v18.00.0.1029 in an upgrade scenario from UE v17.30 (or any other previous version).

            By default there is no template file UETMPLTE.DAT created by any UltraEdit version prior v18.00 as long as the user has not defined templates in the Display/Modify Templates dialog.

            If the user has defined one or more templates (max. 50 prior v18.00), UltraEdit has created an UETMPLTE.DAT file in the directory of uedit32.ini, see UltraEdit INI file location. I use in the description below the synonym IniDir for this directory.

            It was possible and is still possible to specify at Advanced - Configuration - Directories a different Template directory for the template file(s). Of course the user should have write permissions on this directory or modifying of the templates is not possible and automatic upgrade as described below fails too. I use in the description below the synonym TplDir for this directory.

            On start of UltraEdit after upgrading following is done by uedit32.exe regarding template file(s) management:
            • UltraEdit checks if in IniDir a subdirectory named templates exist. If this is not the case as on first start after an upgrade, UltraEdit creates this subdirectory. It does not matter if a TplDir is configured, the templates directory is always created in IniDir. It remains empty if a TplDir is configured.
               
            • Next UE looks in TplDir or if not configured in IniDir for a file with name UETMPLTE.DAT. If such a file is present, it converts the templates stored in binary format in this file to XML format and saves the templates with file name UETMPLTE.TPL in TplDir or in directory IniDir\templates.

              The file UETMPLTE.TPL contains the global templates. There is no limit anymore.

              The template file in binary format is kept unmodified for scenarios like a shared IniDir or TplDir used by multiple UltraEdit users not upgrading all at the same time, or for the case that the user upgrades to UE v18.00 without having a valid license for testing new version and later decides to uninstall UE v18.00 and reinstall the licensed previous version. UETMPLTE.DAT can be deleted manually if a downgrade to an UE version prior v18.00 will surely never take place.
               
            • Independent of the conversion and creation of a global template file, UltraEdit creates next in IniDir\templates or in TplDir a subdirectory named environment.

              In this directory 6 *.tp1 files are created for the 6 standard environments if there are no *.te1 files present in IniDir from an UltraEdit version prior v18.00. The files are empty files for the environments Notepad Replacement, Power User and Programmer because no standard templates are defined for these environments.

              UltraEdit converts existing *.te1 environment template files in IniDir to *.tp1 files into the environments templates directory in an upgrade scenario. The existing *.te1 environment template files remain in IniDir for the same reason as UETMPLTE.DAT is not deleted automatically after conversion. The *.te1 files can be deleted manually in IniDir if a downgrade to an UE version prior v18.00 will surely never take place.
               
            • Further UE creates another subdirectory named language in IniDir\templates or in TplDir and copies to this directory the 13 *-tpl.xml files for the 13 standard syntax highlighting languages installed with UltraEdit into directory template\language in program files directory of UltraEdit. All of them contain predefined templates.
            After this upgrade is done once, the user can modify the global, environment and language templates as wanted with adding also templates for self-created environments or self-added syntax highlighting languages.

            So if there are no templates after upgrade although you had defined templates in a previous version of UltraEdit, you either use a different user account as before upgrade, or UltraEdit could not create the subdirectories and files in TplDir because of missing permissions.

            13
            Basic UserBasic User
            13

              Mar 17, 2012#6

              Hi Mofi,

              and thanks a lot for your explanations. But it seems something weird is going on here on my Windows 7 x64.

              I do have a folder "templates" in %AppData%\IDMComp\UltraEdit\ and another one in C:\Program Files (x86)\IDM Computer Solutions\UltraEdit\. While the one in %AppData% (there would be my .ini location) is completely empty, the other one at least contains the folder language with the mentioned 13 predefined XML files.

              I do not have any subfolder with a name like environment, nor can I find UETMPLTE.DAT or UETMPLTE.TPL ... :( All folders would have write perms at least for SYSTEM, %USERNAME% and ADMINISTRATOR.

              I don't really need my old template file for conversion since I can recreate them easy and fast. But what happening is that I can view/edit templates ("Textbausteine anzeigen/ändern" in my German version) but all are empty. I can add a new template with [+] and by default it gets the name "Template #1". No error messages turn up at "Apply" and/or "OK". But when I open the same window again, it is again all empty.

              I already tried to add manually the mentioned file UETMPLTE.TPL (for testing just a copy of php-tpl.xml) in both template folders, I tried to copy the folder language from the program folder into the %AppData% folder, but all without any success.

              Greetings
              FoTo50

              6,688587
              Grand MasterGrand Master
              6,688587

                Mar 17, 2012#7

                I'm using English version of UltraEdit. It could be that the German version has a bug not existing in English version of UE. You should report to IDM by email that templates created in previous UE are not converted and newly defined global templates are not stored.

                If you want to find out first which files and directories accessed by UltraEdit for templates storing, I suggest to download Process Monitor of Sysinternals (Microsoft) and unpack this free tool to any directory on local disk. Start Process Monitor as Administrator (important). You see first the filter dialog.

                Define a filter with Process Name is uedit32.exe then Include to monitor all UltraEdit activities, or alternatively Path contains UltraEdit then Include to monitor all activities on UltraEdit directories. Close the filter dialog with button OK.

                Process Monitor is now running and you may already see lots of lines. Next look on right side of the toolbar of Process Monitor. You see there 5 icons. Uncheck all except the second one with the magnifying glass over a filing cabinet to log and monitor only file system activities.

                Click on 5th icon from left in the toolbar of Process Monitor or press Ctrl+X to clear the list.

                Now start UltraEdit, open the Modify Templates dialog, define a template and close the dialog with button OK. Switch back to Process Monitor and check the log.

                Do you see why no template files are created?

                You can save the Process Monitor log into a file and upload the file packed with ZIP or RAR here for analyzing by me, or sent the file as attachment by email to IDM support together with a description about the problem.

                13
                Basic UserBasic User
                13

                  Mar 17, 2012#8

                  Thanks a lot Mofi!

                  Checking with your procedure, I found that UE is looking for UETMPLTE.TPL in the folder C:\Program Files\IDM Computer Solutions\UltraEdit instead of the installation path C:\Program Files (x86)\IDM Computer Solutions\UltraEdit. Adding these folders manually and adding an empty UETMPLTE.TPL in there ... viola ... the templates get saved! :)

                  As you guessed, this seems to be a bug in the German version and I'll report this to IDM support right now.

                  Even if templates is just a "toy on the side", it became quite handy in my daily work and saves me a lot of typing. Thanks very much for your help   :D

                  Greetings from sunny Tirol  :wink:
                  FoTo50

                  2362
                  MasterMaster
                  2362

                    Mar 17, 2012#9

                    foto50 wrote: Even if templates is just a "toy on the side", it became quite handy in my daily work and saves me a lot of typing.
                    To me, templates were a "toy on the side" for a long time. They just weren't useful enough because of the limitations, as I needed much more templates than what was allowed, and having to scroll, point, and click, made them too cumbersome to use to the point that it was just as easy to use an external snippet manager to handle it for me. So that's what I did.

                    These new Smart Templates will change all that for me. I would have said "has changed," but unfortunately, I don't get to use them full time until UEStudio gets them. As I get some time available between the thousand other things I have to do, and if I get that time before UEStudio implements them, then I may use UE18 to set them up, and copy them over once I get the new version of UEStudio, which, hopefully, will be the day it is released, unless they release it while I'm on vacation, in which case I plan to take my portable USB drive with me to download while away, so I can install it the minute I get home. I'm that anxious for it after testing it in UE18.

                    I'm very happy about these new Smart Templates...

                    Off-topic Warning
                    Now if we can just get the added features I want to tag lists and macros, I'll be even happier. That would be an automated dialog that would allow the user to import/export tag lists to/from an existing tag file, and import/export plain text file macros to/from an existing binary macro file. Better yet for the macro files, I'd love to see a "compiler" for macros that would compile a plain text macro into the binary format, with the option of inserting it into an existing binary macro file. The compiler would make a "must have" user tool for any power UE user, in my opinion. Copying and pasting into the macro dialog is just plain awkward. Better than a user tool, it would be nice to have the menu option under "Macro" to do just this. Don't they realize we don't use that awful editor in the macro edit/create dialog? Compiler would need to "remove" comments, with comments being actually defined for us to use.

                      Mar 21, 2012#10

                      Okay, I pulled out UE 18 again to do some more testing (because I was going to work on my color scheme management program), and I have hit a snag.

                      I understand perfectly what the "Template placeholder color" is in the Advanced->Configuration->Templates-> section. However, I have yet to figure out what the "Template placeholder color" is used for.

                      Also, I am unable to get UE18 to auto-suggest a smart template unless it is included in the auto-complete dialog, and then it is just the auto-complete dialog showing the templates. I thought there was supposed to be a separate suggestion for templates even when you weren't using the auto-complete dialog... or am I wrong in this? Should this be where the "Auto-suggested template colors" comes in? I have the "...after pausing for: ____ ms" set to 200, but it never appears. The templates appear correctly in my Template List, but do not auto-suggest unless I auto-complete. What's up here?

                      Also, I'll need to send another email to IDM. They left mention of the border colors for these 2 items in the Help file, but removed the border colors from the program toward the end of beta cycle. Help file needs updating. (Only a slight annoyance, but can you imagine the number of people wanting to know why they can't choose the border color, because help says they can?)

                      6,688587
                      Grand MasterGrand Master
                      6,688587

                        Mar 21, 2012#11

                        I have configured a template with name img with text

                        <img src="[+FileName+]" width=[+Width+] height=[+Height+] alt="^">

                        If I enter now img and wait the configured time for auto-suggestion of a template, following is displayed:

                        AutoSuggestedTemplate.png (790Bytes)
                        Auto suggested img tag with the variables FileName, Width and Height.

                        You see here the two background colors in action. There have been some changes to smart templates auto-suggestion feature and the color settings.

                        The border colors can't be customized at the moment because this not really important feature was not completely working on release and is therefore currently disabled internally. I have asked IDM already some days ago what happend with the border colors and received as reply that these 2 colors will become customizable again when the feature is fully working. UltraEdit adds these 2 colors neveretheless automatically to uedit32.ini with default color values because the border coloring might become available in a future version.

                        There is also a change in auto-suggestion feature in comparison to last beta version. The name of the template must be complete entered case sensitive. That's the reason why I think CamelCase templates names would be in general good to avoid auto-suggestion by mistake when typing text. While in last beta this feature worked also for templates with 1 or more spaces, this caused lots of troubles as I reported quickly to IDM after first public release with several reports. Therefore since build 1025 of UE v18.00.0 only the last entered word is compared with the names of the templates instead of phrases. This has the side effect that auto-suggestion works only for templates with no space character in name. A template name like table head top can be never auto-suggested because of the space characters and the fact that just top is searched in the list of templates. TableHeadTop is therefore better as template name.

                        2362
                        MasterMaster
                        2362

                          Mar 21, 2012#12

                          I see. I misunderstood how the template suggestion works. I was not typing the ENTIRE template name, as I thought I would get a pop-up, similar to auto-complete. I understand now where this works.

                          It also seems you must manually type the entire template name, for example, when you have a template of the same name as another auto-complete entry, if you choose the other auto-complete entry, which most likely came from the wordfile, then it won't auto-suggest a template when you auto-complete. That's where putting the templates to be displayed in auto-complete can come in handy.

                          6,688587
                          Grand MasterGrand Master
                          6,688587

                            Apr 20, 2012#13

                            Some users had problems creating templates for non standard syntax highlighting languages. Therefore I explain here briefly how to create language templates.
                            • Open Advanced - Configuration - Editor Display - Syntax Highlighting. You see in this configuration/preferences dialog either the full path of a wordfiles directory or the full name of a wordfile containing 1 or more syntax highlighting languages.

                              The language templates feature require *.uew files in a wordfiles directory with 1 syntax highlighting language per *.uew file. So if you are still using a single wordfile with multiple syntax highlighting languages, you have to split the wordfile up. You can use either the UECompanion utility by rhapdog or my macro SplitToWordfiles in the SyntaxTools macro file. After splitting the single wordfile up to multiple *.uew files and saving them for example in %APPDATA%\IDMComp\UltraEdit\MyWordfiles, select this directory in the syntax highlighting configuration dialog. Users of UEStudio and UE Portable should use an appropriate other directory path.
                               
                            • Next open all *.uew files stored in the directory as displayed in the syntax highlighting configuration dialog. All of them should contain only 1 syntax highlighting definition.

                              The first line in all *.uew files should start with /Lxx"language name" ...

                              If there are blank lines or other lines above the language definition line (pseudo comment lines), remove them or you will not be able to configure a language template for that syntax highlighting language.

                              And make sure that all *.uew files have a unique language name.

                              Hint: Delete the *.uew files you never use. This speeds up start time of UE/UES.
                               
                            • Click in menu Advanced on menu item Display/Modify Templates, or right click into Template List window and left click on Modify Templates context menu item.
                               
                            • The Modify Templates dialog is opened. On upper right corner of the dialog there is a drop down list listing the template groups with the global, environment and language templates. The names of the language templates are equal the language names found in the *.uew files in the configured wordfiles directory. Select the language for which you want to create templates.
                               
                            • Press the + button to add the first template for that language. When you are finished with defining the language templates, press button OK and the templates will be stored in the right directory with the name of the *.uew file.

                            3
                            NewbieNewbie
                            3

                              May 28, 2012#14

                              I used the template functionality of UltraEdit most of the time until it became difficult to search the template you want because of the volume of template I have. There are only two groupings in the template list; Global and Power User groups. Is it possible to create your own template groups? I would be very interested to know how to create my own template groups.

                              6,688587
                              Grand MasterGrand Master
                              6,688587

                                May 29, 2012#15

                                With UE v18.00 and later there are 3 different types (= you call it groups) of templates.
                                • Global templates
                                  are completely user defined and stored in file UETMPLTE.TPL. The default location is subdirectory templates in the directory of the INI file which is by default %APPDATA%\IDMComp\UltraEdit\templates. Another global template file can be used if configuring Template directory at Advanced - Configuration - Directories. The global templates are always available.
                                • Environment templates
                                  depend on currently used environment, see View - Environments. The environment templates are stored in *.tp1 files in subdirectory environment in the templates directory. So be careful when configuring the templates directory as described above as this requires copying or moving also the environment subdirectory manually to have the environment templates still available after setting a different templates directory. UltraEdit creates on first start after a new installation or after an upgrade from UE < 18.00 default environment templates for the standard environments.
                                • Language templates
                                  depend on syntax highlighting language applied to currently active file. The environment templates are stored in *.xml files in subdirectory language in the templates directory. The file name of a language template is the same as the appropriate *.uew file in the wordfiles directory. UltraEdit creates on first start after a new installation or after an upgrade from UE < 18.00 default language templates for the standard syntax highlighting languages.
                                It is not possible to create your own groups. If you put all your templates into global or an environment templates file, you may use a prefix in the template names as pseudo group to easier find a template in the template list.

                                Since UltraEdit v18.20 and UEStudio v12.20 one more type of templates is available: project based templates. The project template file is configured in the project settings dialog and is loaded/unloaded together with the project.

                                See also Wiki documentations Create / modify templates, Directories, Templates and Template list.
                                And watch also the smart templates video tutorial.