Tapatalk

Indenting php code additionally as block

Indenting php code additionally as block

5
NewbieNewbie
5

    Feb 15, 2009#1

    I've been playing around with the Word Wrap/Tab Settings and Reindent feature as well as the Artistic Style to try and get my php files formatted correctly, but I can't seem to find the magic setting to make it work the way I want. Here is a small sample code formatted using the Reindent feature (I set my tabs at 3):

    Code: Select all

    <html>
       <head>
          <title>Some Title</title>
       </head>
       <body>
          <h1>Heading Here.</h1>
          <?php
          echo "This line was created via php code.<br/>";
          echo "So was this line.<br/>";
          ?>
          But this line wasn't.
       </body>
    </html>
    The HTML pieces are formatted okay, but I want the lines within the <?php and ?> section to be indented one level so that it's not in the same column as the <?php and ?> markers. Like this:

    Code: Select all

          <?php
             echo "This line was created via php code.<br/>";
             echo "So was this line.<br/>";
          ?>
    Is there a way to customize either the Reindent Selection feature or create your own Artistic Style?

    Thanks,
    Richard

    6,685587
    Grand MasterGrand Master
    6,685587

      Feb 15, 2009#2

      A ReIndent Selection test on your example worked as you want it with following settings for /L8"PHP" PHP_LANG in wordfile.uew:

      /Indent Strings = "{" "?php"
      /Unindent Strings = "}" "?>"

      With the 2 additional strings the entire block inside <?php ... ?> is also indented.
      Best regards from an UC/UE/UES for Windows user from Austria

      5
      NewbieNewbie
      5

        Feb 15, 2009#3

        Mofi - Thanks for the suggestion for this problem. I went ahead and made the change to the wordfile.uew file in C:\Program files\IDM Computer Solutions\UltraEdit, closed UltraEdit, reopened it and it still won't reformat the php section. Here are the two lines that I modified in the L8"PHP" section:

        Code: Select all

        /Indent Strings = "{" "?php"
        /Unindent Strings = "}" "?>"
        I also tried "<?php" instead of "?php" and that didn't help. Is there another setting that you can think of that might be controlling this?

        I did notice these lines about 18 lines below where the Unindent Strings line is, but I don't know if they impact the reindenting feature:

        Code: Select all

        /C2"Tags" STYLE_TAG
        <? <?PHP
        ?>
        Thanks,
        Richard

        6,685587
        Grand MasterGrand Master
        6,685587

          Feb 15, 2009#4

          You have made the modifications correct. Those indent/unindent strings produced on my computer the results you wanted. But do you have made it in the correct wordfile?

          Look at Advanced - Configuration - Editor Display - Syntax Highlighting which wordfile is really used. If you upgraded from a pre v14 version of UltraEdit the wordfile in the program directory is no longer used. The wordfile now used is

          %appdata%\IDMComp\UltraEdit\wordfile.uew

          as displayed in the configuration dialog with correct absolute path. Also make sure that you have not currently opened a project with a project specific wordfile.

          The tags in the color group are just for highlighting and don't have any influence on the indent feature.
          Best regards from an UC/UE/UES for Windows user from Austria

          5
          NewbieNewbie
          5

            Feb 15, 2009#5

            Mofi - Herzlichen Dank! Yes, I assumed that the wordfile.uew in use was the one under C:\Program Files, it turns out that I should have been looking at the one in my Documents and Settings folder. I made the change per your original instructions and it worked. I now have it formatting the PHP sections correctly.

            Nochmals, vielen Dank!

            Grüße,
            Richard