Reindent Selection

Reindent Selection

4
NewbieNewbie
4

    Jul 29, 2004#1

    I need help understanding Reindent Selection. I don't understand how to set it up, nor am I certain I understand what it does. Or should do.
    Can someone explain it in exquisite detail?
    Step by step. What configuration options go in the Advanced menu, what configuration option go in the WordFile, what do I do, what should I see in my file as a result.

    Steve Auerbach

    80
    Advanced UserAdvanced User
    80

      Jul 30, 2004#2

      If you highlight a block of code and run reindent selection the code will be indented based on the settings in the wordfile.

      So in C++ code that looks like this:

      Code: Select all

      TEST_MAIN(void)
      {
      printf("\nTEST Begin...\n\n");
        }
      
      Would end up looking like this:

      Code: Select all

      TEST_MAIN(void)
      {
        printf("\nTEST Begin...\n\n");
      }
      

      4
      NewbieNewbie
      4

        Jul 30, 2004#3

        Thank you that's helpful.

        BUT what settings in the WORDFILE??

        6,675585
        Grand MasterGrand Master
        6,675585

          Jul 30, 2004#4

          In the wordfiles the characters or even whole words, which are the identifier for indentation for the specific language must be defined - see also help of UE about indentation.

          Examples:

          for language C/C++:

          /Indent Strings = "{" ":"
          /Unindent Strings = "}"

          for pascal:

          /Indent Strings = "BEGIN" "CASE" "DO" "ELSE" "THEN"
          /Unindent Strings = "END;" "END"

          In the Advanced - Configuration - Edit dialog you can specify, if tabs or spaces are used for indenting the text and how many spaces the indentation should be. This can be set differently for different languages respectively file extensions. In this dialog, also the Auto Indent feature can be enabled/disabled, which forces indentation during writing if enabled.
          Best regards from an UC/UE/UES for Windows user from Austria

          4
          NewbieNewbie
          4

            Aug 10, 2004#5

            Still not working here.
            I have auto indent working and it indents and outdents properly as I type, but I can not get Reindent Selection to do a thing!
            Do I select the words that bracket the beginning and the end of the selection to be indented, or only select the lines in the middle that are to be moved?
            I tried both and neither seems to do a thing.
            In the language I use I type IF. I indent and type lines of code, then I type ENDIF and UE lines up ENDIF with the IF.
            But when I type all the lines in col 1, select the code (with or without the IF / ENDIF) nothing happens.
            Interestingly, if I indent the entire block 3 spaces and then try it, all the code jumps to column 1.

            6,675585
            Grand MasterGrand Master
            6,675585

              Aug 11, 2004#6

              You have to select all lines from the IF to the ENDIF including the IF and ENDIF line. Example:

              Code: Select all

              IF condition 1
                      code line 1
                code line 2
                   code line 3
                 IF condition 2
                  code line 4
                    code line 5
                 ENDIF
               code line 6
                  code line 7
              ENDIF
              If all these lines are selected and you use reindent you should get following:

              Code: Select all

              IF condition 1
                 code line 1
                 code line 2
                 code line 3
                 IF condition 2
                    code line 4
                    code line 5
                 ENDIF
                 code line 6
                 code line 7
              ENDIF
              Hope this helps and works. I have not tried it with IF and ENDIF as indent and unindent string.
              Best regards from an UC/UE/UES for Windows user from Austria

              80
              Advanced UserAdvanced User
              80

                Aug 11, 2004#7

                It's normal that everything jumps to column 1. Since only the selection is considered UE thinks it should be aligned to the left most column.

                4
                NewbieNewbie
                4

                  Aug 11, 2004#8

                  I made sure that If was in the INDENT line and Endif in UNINDENT line and tried the example and it does nothing at all.

                  6,675585
                  Grand MasterGrand Master
                  6,675585

                    Aug 11, 2004#9

                    I played a little bit with my example and found out, that it is really not indented correct and also why.

                    After the indent string IF only white characters are allowed in the same line. And in the line with the the unindent string ENDIF only white characters are allowed before the unindent string.

                    So this example is the correct one:

                    Code: Select all

                    any text IF
                            code line 1 
                      code line 2 
                         code line 3 
                       any text IF
                        code line 4 
                          code line 5 
                       ENDIF any text
                     code line 6 
                        code line 7 
                    ENDIF any text
                    Which is reindented to:

                    Code: Select all

                    any text IF
                       code line 1
                       code line 2
                       code line 3
                       any text IF
                          code line 4
                          code line 5
                       ENDIF any text
                       code line 6
                       code line 7
                    ENDIF any text
                    I wrote to IDM for a long time ago, that the reindent is not working correctly, if there is more than one unindent string in a line. I often use in language C for example }}} in one line to close 3 loops/conditions.

                    Now I know, that there are more problems with reindention. Who else has found special situations, where the reindent is not working as expected?
                    Best regards from an UC/UE/UES for Windows user from Austria

                    80
                    Advanced UserAdvanced User
                    80

                      Aug 12, 2004#10

                      For C++, C, and Java code I've found Artistic Style to be a much better reindenter. I setup a macro to run it on the current selection.
                      http://astyle.sourceforge.net/

                      Here's my tool setting.

                      "C:\Program Files\astyle_1.15.3_win32\astyle.exe" --style=ansi --mode=c --convert-tabs --indent=spaces=2 --indent-cases C:\Windows\Temp\Astyle.tmp

                      Here's the macro that calls the tool.

                      InsertMode
                      ColumnModeOff
                      HexOff
                      UnixReOff
                      Copy
                      NewFile
                      Paste
                      SaveAs "C:\Windows\Temp\Astyle.tmp"
                      CloseFile
                      RunTool "Astyle Selection"
                      Open "C:\Windows\Temp\Astyle.tmp"
                      SelectAll
                      Copy
                      CloseFile
                      Paste

                      3
                      NewbieNewbie
                      3

                        Oct 08, 2004#11

                        Mofi wrote:...
                        After the indent string IF only white characters are allowed in the same line. And in the line with the the unindent string ENDIF only white characters are allowed before the unindent string.
                        ...
                        Has anyone tried to do something like this?

                        Code: Select all

                        /Indent Strings = "IF ^([A-Z _ 0-9 a-z]+^)"
                        /Unindent Strings = "END_IF ^([A-Z _ 0-9 a-z]+^)"
                        
                        I can't get it work, but this could be an error of the ^([A-Z _ 0-9 a-z]+^) syntax :?

                        I think it is very strange that it is not allowed to have a character behind the indent string. How many languages force you to add a condition behind the if? Quiet a lott suppose.... :cry:

                        Best regards,

                        Harry.

                        6,675585
                        Grand MasterGrand Master
                        6,675585

                          Oct 08, 2004#12

                          Regular expressions are not possible for indent and unindent strings. Regular expressions can only be used for the function strings.

                          All other definitions in the wordfile are simply words, where strcmp() or stricmp() is used. (Except ** word definitions where strncmp() or strnicmp() is used, I guess).
                          Best regards from an UC/UE/UES for Windows user from Austria

                          2
                          NewbieNewbie
                          2

                            Oct 28, 2004#13

                            Hi, Mofi, I read this message from you:
                            Mofi wrote:I played a little bit with my example and found out, that it is really not indented correct and also why.

                            After the indent string IF only white characters are allowed in the same line. And in the line with the the unindent string ENDIF only white characters are allowed before the unindent string.
                            I saw in the help that you can set UE to recognise not the LAST chars in a line, but the FIRST ones just by using the command:
                            /Indent Strings SOL = ...
                            instead of:
                            /Indent Strings = ...

                            In either case my Reintend Selection command does not work, but this is just a note on your message, hope it is useful for everybody.
                            Regards,
                            MDI

                            6,675585
                            Grand MasterGrand Master
                            6,675585

                              Oct 28, 2004#14

                              Thanks mdimdi to add the second indent string definition here.

                              This could be helpful at some languages, but it is not helpful on my examples. Both are not reindented correct, when /Indent Strings SOL = is used instead of /Indent Strings =.
                              Best regards from an UC/UE/UES for Windows user from Austria

                              3
                              NewbieNewbie
                              3

                                Oct 29, 2004#15

                                Thanks mdimdi for the suggestion, my problem is solved!

                                Now I have added this line to my definition file:


                                /Indent Strings SOL = "DEFINE" "ELSE" "ELSE_IF" "IF" "WHILE"


                                Best regards,

                                Harry

                                Read more posts (2 remaining)