Sublime Forum

Line Reindent [Sublime Text 3 3143] - Stop Working

#1

Good evening, community.

I always organized my code using the following actions!

Select all code, then EDIT> LINE> REINDENT

And it always worked but after update 3143 I can not get the same result.

The only problem is in the organization of the code within php ECHO.

Example Basic.

BEFORE 3143:

echo '
<table class="table table-bordered table-striped sup1em" id="tableResponsive">
   <thead>
      <tr>
          <th class="text-center linhaStatus">ID Pedido</th>
          <th class="text-center">Cliente / Destino</th>
          <th class="text-center">Pedido</th>
          <th class="text-center linhaStatus">Gerenciar</th>
      </tr>
   </thead>
<table>';

THEN 3143:

echo '
<table class="table table-bordered table-striped sup1em" id="tableResponsive">
<thead>
<tr>
<th class="text-center linhaStatus">ID Pedido</th>
<th class="text-center">Cliente / Destino</th>
<th class="text-center">Pedido</th>
<th class="text-center linhaStatus">Gerenciar</th>
</tr>
</thead>
<table>';

Has anyone gone through this? Or would you have another solution !?

I only work with HTML, JS, PHP and CSS.

1 Like

#2

You could do the following to ensure that reindent doesn’t touch your strings:

  • Tools menu -> Browse Packages
  • Create PHP folder if it doesn’t already exist
  • Go into PHP folder
  • Create a new text file
  • Open it and paste in the following
<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
	<key>name</key>
	<string>Indentation Rules Annex</string>
	<key>scope</key>
	<string>source.php string</string>
	<key>settings</key>
	<dict>
		<key>unIndentedLinePattern</key>
		<string>.</string>
	</dict>
</dict>
</plist>
  • save it
  • rename it to IgnoreStrings.tmPreferences
  • try reindenting your PHP example again
0 Likes

#3

First of all thank you!

But this solution just ignores it and as if the REINDENT treatment ignored those parts of the code.

But in the old days he also organized the content within ECHO.

This solution just ignores, would need something to organize as it was done before.

Anyway thank you very much for the answer.

0 Likes

#4

alternatively, you could get your PHP strings to be treated as HTML for indentation purposes:

  • Tools menu -> Browse Packages

  • Go into PHP folder and delete the IgnoreStrings.tmPreferences we created earlier

  • Install https://packagecontrol.io/packages/PackageResourceViewer if it isn’t already installed

  • Open the Command Palette

  • Type PRV: O and select PackageResourceViewer: Open File

  • Select HTML

  • Select Miscellaneous.tmPreferences

  • Find/Select <string>text.html</string>

  • Replace it with <string>text.html, embedding.php text.html.basic source.php meta.embedded.html text.html, embedding.php text.html.basic source.php string</string>

  • Save it

  • Try reindenting your file again

It may not be perfect because you have HTML on the last line of your string - for best results, I think it would be better to end your string with a blank line, just like you started the string with a blank line.

0 Likes

#5

PERFECT!

Thank you very much!

0 Likes