Indenting php code additionally as block

Syntax highlighting, code folding, brace matching, code indenting, and function list

Indenting php code additionally as block

Postby vgehts » Sat Feb 14, 2009 10:10 pm

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
vgehts
Newbie
 
Posts: 5
Joined: Sat Feb 14, 2009 9:44 pm
Location: Saint Louis, MO USA

Re: Indenting php code additionally as block

Postby Mofi » Sun Feb 15, 2009 9:01 am

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.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4054
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: Indenting php code additionally as block

Postby vgehts » Sun Feb 15, 2009 12:02 pm

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
vgehts
Newbie
 
Posts: 5
Joined: Sat Feb 14, 2009 9:44 pm
Location: Saint Louis, MO USA

Re: Indenting php code additionally as block

Postby Mofi » Sun Feb 15, 2009 1:05 pm

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.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4054
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: Indenting php code additionally as block

Postby vgehts » Sun Feb 15, 2009 5:29 pm

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
vgehts
Newbie
 
Posts: 5
Joined: Sat Feb 14, 2009 9:44 pm
Location: Saint Louis, MO USA


Return to Syntax Highlighting