Smart Templates for HTML

Smart Templates for HTML

912
Advanced UserAdvanced User
912

    Nov 08, 2022#1

    Hi.

    Next week, I'll use UltraEdit as a HTML editor for a while and would like to know where I can find a Smart Template file with the basic tags.
    Yes, I know that I can write my own list of tags, but if there are a file which I can download, it would be far better.

    Also, I'd like to know how to invoke those menu buttons, like "HTML bullets", "HTML align left", "HTML text area", etc.
    If I type CTRL-Space, it opens a general list with my Global Template Group.
    How to invoke, by keyboard, only HTML tags, when I type its first characters?

    Thanks.

    6,624550
    Grand MasterGrand Master
    6,624550

      Nov 08, 2022#2

      Automatically close XML/HTML tags

      An UltraEdit user can type the start tag of an HTML element and UltraEdit inserts automatically the appropriate closing tag if that feature is enabled in configuration as by default. That is the most efficient method to write text in HTML embedded in basic tags like <em>...</em>.

      Tag List

      There is by default installed also a tag list file containing the HTML related tag groups HTML - Special Characters and HTML - Tags. Those tags can be inserted by opening the Tag List view and double clicking on a tag in the view. How the view is opened depends on used version of UltraEdit for Windows and the user interface mode not mentioned in initial post.  It is possible to select the text before double clicking on an item in this list view which results in enclosing the selected text in the inserted tags as long as the HTML element has a start and an end tag at all.

      Note: If the currently used version of UltraEdit was upgraded from an older version and there was never customized the tag groups and tags in the tag list file, it would be a good idea to make sure using the latest version of the tag list file as installed with UltraEdit and not an older version of the tag list file from an older version of UltraEdit. The necessary steps to manually update the tag list file are for UltraEdit for Windows v2022.1.0.112 as follows:
      1. Open in UltraEdit the file taglist.uet (ANSI encoded) in program files folder of installed UltraEdit which is by default %ProgramFiles%\IDM Computer Solutions\UltraEdit or %ProgramFiles(x86)%\IDM Computer Solutions\UltraEdit.
      2. Use the command Save as (key F12) and save the file into the default application data folder %APPDATA%\IDMComp\UltraEdit with the file name TAGLISTU.UET (Unicode encoded) with changing the option Encoding to UTF-16 (with BOM) before clicking on button Save.
      3. Delete in folder  %APPDATA%\IDMComp\UltraEdit the files taglist.uet and taglist.txt which are ANSI encoded versions of the tag list file from older versions of UltraEdit if those files exist at all.
      4. Restart UltraEdit to load the tags as defined in %APPDATA%\IDMComp\UltraEdit\TAGLISTU.UET.
      It is advisable to store customizations not in the file %APPDATA%\IDMComp\UltraEdit\TAGLISTU.UET although that is possible. I suggest to configure in Tag List Modify dialog window a different file than the default %APPDATA%\IDMComp\UltraEdit\TAGLISTU.UET on making customizations like deleting tag groups never needed (for faster load/startup), adding tag groups, adding tags or customizing tags. I use a file with name MyTagList.uet in folder  %APPDATA%\IDMComp\UltraEdit which is also encoded with UTF-16 with BOM. Right click into the Tag List view and click on the context menu item Modify tags to open the Tag List Modify dialog window which is resizable and where the file with the tag list can be selected.

      HTML user tools

      The HTML user tools are more or less the same as the tags in the tag list file with the following differences in comparison to the tags:
      1. There are predefined tags which on insert trigger extra code inside UltraEdit like for the lists to convert a selected text block into a real HTML formatted list.
      2. The HTML user tools can be customized in configuration at Advanced - Settings or Configuration - Toolbars / menus / HTML user tools with the exception of those with special program code.
      3. The HTML user tools configuration is stored in %APPDATA%\IDMComp\UltraEdit\ue.ini on using UltraEdit for Windows v2022.1.0.112.
      4. The HTML user tools have associated icons and the most often need and predefined HTML user tools are shown on ribbon tab Coding (ribbon mode) as well as toolbar HTML user tools (both toolbar/menu modes) whereby the toolbar HTML user tools is by default not visible. The visibility of the HTML user tools toolbar must be toggled on in both toolbar/menu modes.
      Please read also HTML toolbar using deprecated elements B and I instead of STRONG and EM (solved) as the HTML user tools customization is a bit tricky because of the customization is not yet implemented completely again as it was up to UltraEdit for Windows v22.20.

      Smart templates

      The smart templates replace more or less the older tags in tag list view. A smart template can be inserted also by using a view which is in this case the Template List view. But one big advantage of a smart template in comparison to a tag is the ability to insert a smart template by typing its name on Auto-suggest smart template when typing being enabled as by default at Advanced - Settings or Configuration - Templates.

      Another advantage of smart templates is the possibility to define them with parameters of which values are defined while inserting a smart template.

      The indentation can be taken into account on inserting a smart template which is not the case on inserting a tag from the tag list group. Well, the tags in a tag list group are usually not defined as multi-line tags although that is possible and I have defined some tags as multi-line tags in my custom tag list file.

      There are four different type of smart templates:
      1. Global templates are always accessible at any time. It is not possible to turn off suggesting global templates. A good naming scheme for the templates prevents suggesting global templates when not really needed. There can be defined all global templates with a specific prefix in name which can be a string like glb or g_ or just _ or #.
      2. Layout templates are associated with a specific layout. Layout templates are useful for UltraEdit users using multiple layouts like using a layout for C/C++ code writing and another for HTML files editing and a third one for Java development. Then the layout templates for the layout used for C/C++ development could contain the smart templates always needed for C/C++ source code writing while the layout templates for HTML files editing could contain smart templates generally used on HTML editing independent on caret is in active HTML file in an HTML, a CSS, a JavaScript or a PHP block.
      3. Language templates are associated with a specific syntax highlighting language. The language templates are accessible if the text at current position of caret in active file is syntax highlighted with the associated syntax highlighting language.
      4. Project templates are associated with a specific project. Project templates are very useful for HTML writers working for various websites with different cascading style sheet classes. The usage of a project for each website makes it possible to use also smart templates with CSS class references suitable for the website/project currently opened with project template names being identical in all project template files for a similar element. For example the head block of each webpage of website A is different to the head block of each webpage of website B. The smart project template for inserting the head for website A differs for that reason from the smart project template for inserting the head for website B, but the project template name of the template to insert the head block into a new HTML file is the same in all project template files.
      The smart language template for HTML installed by UltraEdit contains some predefined templates. But the main advantage of smart templates is the customization to fit exactly to the personal needs. This is the reason why I don't share my templates public with anybody else. My smart templates for batch file coding, C/C++ coding, UltraEdit/UEStudio script coding, HTML files editing for various websites, etc. are all customized perfectly to my requirements and are not of general usage. I use a naming scheme for all my templates making it very efficient for me to insert them by key and nevertheless know at any time which characters to insert into active file (= keys to press) to get the smart template suggested for inserting which I want to insert now from global, layout, language or project templates list.
      Best regards from an UC/UE/UES for Windows user from Austria

      912
      Advanced UserAdvanced User
      912

        Nov 08, 2022#3

        Mofi, thank you very much for your full explanation of the subject.

        Automatically close XML/HTML tags

        I wasn't aware of this trick. Nice.


        Tag List

        In fact, I had no TAGLISTU.UET file at all.
        I did as you told to do and I could have a Tag List view populated with tags for:

        HTML - Special Characters
        HTML - Tags
        COLD FUSION - Tags
        UE/UES Macro Commands
        UE/UES Script Commands

        Very nice!

        But...
        Something is going wrong.

        If I double click one of the tags, I get this:

        Code: Select all

        <can</canvas>vas>

        If some text is selected, ex. "abcdefghij", I get this:

        Code: Select all

        <canvas>abcdef</canvas>ghij

        I repeated all steps to create the file TAGLISTU.UET, but this behavious was the same.
        I inspected what could be wrong at the Tag List Modify window, but everything seems right.
        I have no clue for what is wrong here.
        It breaks the text 4 characters before its end.

        I understood about to have a customized MyTagList.uet file for my own needs.

        HTML User Tools

        Good to know more about it, but it is not my goal to use, because it requires too many mouse actions and I prefer use more the keyboard.

        Smart Templates

        My installed version of UltraEdit, 28.20.0.44, has a template group named HTML, but it's empty.
        All other groups, Batch, C/C++, Java, JSON, Python,... are all empty too.
        How to have, at least HTML template group with basic tags in it?

        6,624550
        Grand MasterGrand Master
        6,624550

          Nov 09, 2022#4

          Tag List

          You are right, inserting HTML tags from the Tag List view is not working correct on active file is a Unicode file encoded with UTF-16 LE. It works fine for ANSI and UTF-8 encoded files which I suggest to use on writing HTML files. I have just reported this issue to UltraEdit support with the following email.

          A user of UltraEdit detected by chance an issue with inserting an HTML tag from the Tag List view with UltraEdit for Windows v28.20.0.44 which I could reproduce with v2022.1.0.112. It does not work correct if the active file is UTF-16 LE encoded. It works as expected for ANSI and UTF-8 encoded files.

          The steps to reproduce are:
          1. Start UltraEdit with the default settings.
          2. Convert the new, empty file to Unicode (UTF-16 LE).
          3. Open the Tag List view.
          4. Select the tag group HTML - Tags and double click on the item Canvas. There is inserted now:
            <can</canvas>vas>
            But there should be inserted <canvas></canvas> with the caret between the two tags.
          5. Press key END and next RETURN and type the string: HTML tag
          6. Select with Shift+HOME the just typed string and double click once again on the item Canvas in Tag List view. There is displayed now:
            <canvas>HTML</canvas> tag
            But there should be <canvas>HTML tag</canvas> in active file.

          Smart templates

          There is in program files directory of UltraEdit the subdirectory template which contains the default language templates for syntax highlighting languages installed by default with UltraEdit. Copy the *-tpl.xml files from this directory into the directory %APPDATA%\IDMComp\UltraEdit\templates\language to update the user customizable language templates files. There should be deleted the template files in the language folder for which no syntax highlighting wordfile exists in folder %APPDATA%\IDMComp\UltraEdit\wordfiles with a language name as defined inside the *.uew files on first line.

          There can be customized at Advanced - Settings or Configuration - Directories the Template directory. I used that configuration setting to define %APPDATA%\IDMComp\UltraEdit\MyTemplates as the template directory containing my customized global, layout and language templates with same folder structure and files as in the default templates directory.

          The default language template file does not contain templates for basic elements like EM, P, SPAN, STRONG, etc. You have to add such templates if you want to use smart templates for basic HTML elements although it makes more sense in general to define smart templates for HTML elements with attributes like the CSS class(es).

          Please note that with the version of UltraEdit for Windows used by you it is possible to drag and drop an image file (GIF, JPG, PNG) from a file manager like Windows File Explorer or from the File explorer view inside UltraEdit into the active document window of an HTML file edited in UltraEdit and UltraEdit inserts the IMG element with the attributes src, alt, height and width at the current caret position. That feature works even for UTF-16 LE encoded HTML files.
          Best regards from an UC/UE/UES for Windows user from Austria

          912
          Advanced UserAdvanced User
          912

            Nov 09, 2022#5

            Mofi wrote:
            Nov 09, 2022
            Tag List

            You are right, inserting HTML tags from the Tag List view is not working correct on active file is a Unicode file encoded with UTF-16 LE. It works fine for ANSI and UTF-8 encoded files which I suggest to use on writing HTML files. I have just reported this issue to UltraEdit support with the following email.
            Good to know it wasn't my fault.

            But I didn't understand why you said to convert taglist.uet (ANSI encoded) to UTF-16 (with BOM), and uppercase (TAGLISTU.UET).
            I did the same copy to %APPDATA%\IDMComp\UltraEdit\ as ANSI encoded and lowercase, deleted the previous Unicode version and got the same Tag List.
            If I use that list to ANSI encoded files, tags are inserted correctly. Problem (bug) only occur if the file is UTF-16.

            Mofi wrote:
            Nov 09, 2022
            Smart templates

            There can be customized at Advanced - Settings or Configuration - Directories the Template directory. I used that configuration setting to define %APPDATA%\IDMComp\UltraEdit\MyTemplates as the template directory containing my customized global, layout and language templates with same folder structure and files as in the default templates directory.
            Thank you. I'll do the same.

            Mofi wrote:
            Nov 09, 2022
            Please note that with the version of UltraEdit for Windows used by you it is possible to drag and drop an image file (GIF, JPG, PNG) from a file manager like Windows File Explorer or from the File explorer view inside UltraEdit into the active document window of an HTML file edited in UltraEdit and UltraEdit inserts the IMG element with the attributes src, alt, height and width at the current caret position. That feature works even for UTF-16 LE encoded HTML files.
            That's fantastic!!!

            6,624550
            Grand MasterGrand Master
            6,624550

              Nov 09, 2022#6

              My instructions on how to update the tag list file replicate what UltraEdit itself does on creating the directory %APPDATA%\IDMComp\UltraEdit and all the subdirectories and files (for a new user or on first start and exit after first installation).

              You can see that by renaming the application data directory UltraEdit to something like UltraEditBackup while no instance of UltraEdit is running and start next UltraEdit. There is shown the Welcome window and the entire directory %APPDATA%\IDMComp\UltraEdit with all its subdirectories and files is created new by UltraEdit using the default settings with exception of the changes made in Welcome window after exit of UltraEdit.

              You can see after exit of UltraEdit that UltraEdit copied taglist.uet from program files directory to the newly created application data directory with changing the file name to TAGLISTU.UET and the encoding from ANSI to UTF-16 LE. The tag list file TAGLISTU.UET is used also by UltraEdit for the Tag List view.

              Your configuration can be restored by deleting newly created application data directory UltraEdit or renaming it to UltraEditStandard while no instance of UltraEdit is running and rename back UltraEditBackup to just UltraEdit.

              BTW: The reported issue could be reproduced by UltraEdit support and is added to the issues database for investigation by an UltraEdit developer.
              Best regards from an UC/UE/UES for Windows user from Austria

              912
              Advanced UserAdvanced User
              912

                Nov 09, 2022#7

                All my demands were fully satisfied.

                I'd like to say a BIG thanks to you, Mofi.
                Nowhere else the user can receive more attention than here, in your forum.

                And I'm happy to give a very small contribution to solve a little bug.

                6,624550
                Grand MasterGrand Master
                6,624550

                  Jan 21, 2023#8

                  The issue with wrong inserting of an HTML tag from the tag list view into active UTF-16 encoded file is fixed with UltraEdit for Windows v2022.2.0.34 and UEStudio v2022.2.0.34.
                  Best regards from an UC/UE/UES for Windows user from Austria