Template alignment is messed up

Template alignment is messed up

6

    4:31 - Feb 29#1

    Hi all!

    Some time ago, an update to UE started messing with my templates. Yes, I know, I should have reported it straight away, but I had other things that were more urgent at the time.
    By now, I am so annoyed by this, that I figure it is time to get this sorted out.

    I have a lot of self-created templates I use, mostly for SAS coding. The templates use alignment to indent code blocks, and since some of the templates are quite long, this is incredibly helpful, and incredibly annoying when it gets messed up. I will give a brief example below, but let me draw attention to the fact that some of these templates are many years old, have always worked, and have been broken some time in the recent past, not by changes to the templates, but by an UltraEdit update.

    Fixes I have tried are:
    1. Rebuilding the template, using only spaces for alignment. Didn't work.
    2. Rebuilding the template, using only tabs for alignment. Didn't work.
    Here is an example of a short template:

    Code: Select all

    PROC MEANS
        DATA=
        MAXDEC=3 N NMISS RANGE MIN Q1 MEDIAN Q3 MAX MEAN STDDEV ALPHA=0.05 CLM SKEW KURT; 
        VAR ;
        CLASS ;
      /*WHERE ;*/
        TITLE "";
    RUN;
    And this is what I get when I insert it:

    Code: Select all

    PROC MEANS
            DATA=
                MAXDEC=3 N NMISS RANGE MIN Q1 MEDIAN Q3 MAX MEAN STDDEV ALPHA=0.05 CLM SKEW KURT; 
                VAR ;
                CLASS ;
              /*WHERE ;*/
                TITLE "";
        RUN;
    Please can someone fix this?

    Thanks.

    6,688586
    Grand MasterGrand Master
    6,688586

      6:36 - Feb 29#2

      There are needed some information about configuration settings and some files for a user to user help on this issue. Please pack into a 7-Zip, RAR or ZIP archive file:
      1. The template file with the SAS templates used by you as stored by default in the directory %APPDATA%\IDMComp\UltraEdit\templates\language on being language templates as expected respectively in the subdirectory language of the directory configured at Advanced - Settings or Configuration - Directories under the item Template directory.
      2. The syntax highlighting wordfile for SAS syntax highlighting used by you as stored by default in the directory %APPDATA%\IDMComp\UltraEdit\wordfiles respectively in the directory configured at Advanced - Settings or Configuration - Editor display - Syntax highlighting at top.
      3. A small example SAS file.
      Please add this archive file as file attachment to your next post by using the button Full Editor & Preview at the bottom of this forum page.

      Next we need information about the tab settings for SAS files configured at Advanced - Settings or Configuration - Editor - Word wrap / tab settings. Select at top of this configuration window the list item for SAS files on having configured a file extension list for SAS files or Default on no special file extension based settings for SAS files and tell us the configuration for following settings:
      • Use spaces in place of tabs
      • Tab stop value
      • Indent spaces
      Further are needed information about your indent settings at Advanced - Settings or Configuration - Editor display - Formatting for:
      • Auto indent new lines
      • Auto indent wrapped lines
      Last but not least tell us the status of the setting Maintain indent level when inserting template at Advanced - Settings or Configuration - Templates.

      All these configuration settings and the indent/unindent strings definition in the syntax highlighting wordfile and the kind of template definition must match together.

      Please see also the topic: Empty lines after inserting the default smart language template HTML5 into a new HTML file (fixed)
      Best regards from an UC/UE/UES for Windows user from Austria

      6

        23:50 - Feb 29#3

        Editor - Word wrap / tab settings
        • Use spaces in place of tabs: True
        • Tab stop value: 4
        • Indent spaces: 4
        Editor display - Formatting
        • Auto indent new lines: True
        • Auto indent wrapped lines: True
        Templates
        Maintain indent level when inserting template: True
        UE-SAS.zip (14.86 KiB)   0

        6,688586
        Grand MasterGrand Master
        6,688586

          6:44 - Mar 01#4

          Thank you for the files and the information about the related configuration settings. I could easily reproduce the issue with them and find the solution.

          The syntax highlighting wordfile sas.uew contains the two lines:

          Code: Select all

          /Indent Strings = "%macro" "data" "do" "proc" "{"
          /Unindent Strings = "%mend" "end;" "run;" "quit;" "}"
          The first line with the used configuration settings results in adding four indent spaces on a line inserted below a line containing case-insensitive either %MACRO or DATA or DO or PROC or {. The template Proc Means inserts first the line:

          Code: Select all

          PROC MEANS
          This line contains the indent string PROC and the next line is automatically indented for that reason with four spaces automatically. The template Proc Means must be defined therefore without four indent spaces as that indent is done automatically with the used configuration settings making all sense for SAS editing. The template Proc Means should be defined with:

          Code: Select all

          PROC MEANS
          DATA=
          MAXDEC=3 N NMISS RANGE MIN Q1 MEDIAN Q3 MAX MEAN STDDEV ALPHA=0.05 CLM SKEW KURT; 
          VAR ;
          CLASS ;
          /*WHERE ;*/
          TITLE "";
          RUN;
          The next issue to solve is the automatic indent on template insert after there is inserted automatically indented the second line:

          Code: Select all

          DATA=
          That line contains the indent string DATA although it is obviously not a DATA Statement if I understood the SAS syntax right. There must be changed in the wordfile sas.uew the indent string definition "data" to "data " with a space after the keyword DATA to indent the next line only on a DATA statement but not on DATA= with an equal sign.

          The result on inserting the modified template Proc Means with modified indent string "data " in the wordfile sas.uew results in inserting into the file example.sas the block:

          Code: Select all

          PROC MEANS
              DATA=
              MAXDEC=3 N NMISS RANGE MIN Q1 MEDIAN Q3 MAX MEAN STDDEV ALPHA=0.05 CLM SKEW KURT; 
              VAR ;
              CLASS ;
              /*WHERE ;*/
              TITLE "";
          RUN;
          
          It is of course not possible to have the commented line unindented by two spaces as a negative unindent cannot be defined in the template file.

          It is perhaps better to define the template Proc Means with:

          Code: Select all

          PROC MEANS
          DATA=
          MAXDEC=3 N NMISS RANGE MIN Q1 MEDIAN Q3 MAX MEAN STDDEV ALPHA=0.05 CLM SKEW KURT; 
          VAR ;
          CLASS ;
          WHERE ^;
          TITLE "";
          RUN;
          The WHERE statement is not commented in this case. There is ^ now in the line marking the position where the text cursor (caret) should be positioned after inserting the entire template. The template is inserted now as:

          Code: Select all

          PROC MEANS
              DATA=
              MAXDEC=3 N NMISS RANGE MIN Q1 MEDIAN Q3 MAX MEAN STDDEV ALPHA=0.05 CLM SKEW KURT; 
              VAR ;
              CLASS ;
              WHERE |;
              TITLE "";
          RUN;
          The character | in the code block above shows where the text cursor is positioned and blinking after inserting the line. This line can now be deleted by pressing the hotkey assigned to the command Delete line which is by default Ctrl+E on not needed at all, or the string is entered to complete now the WHERE statement.

          I think best would be the template Proc Means is defined with:

          Code: Select all

          PROC MEANS
          DATA=[+data+]
          MAXDEC=3 N NMISS RANGE MIN Q1 MEDIAN Q3 MAX MEAN STDDEV ALPHA=0.05 CLM SKEW KURT; 
          VAR [+var+];
          CLASS [+class+];
          WHERE ^;
          TITLE "[+title+]";
          RUN;
          Then the data, variable, class and title can be input already while inserting the template and the caret is positioned on the WHERE statement after finishing the insert of the template to either delete the line with Ctrl+E or enter here the string to complete the WHERE statement.
          Best regards from an UC/UE/UES for Windows user from Austria