Sublime Forum

Indent guides not working correctly in php files

#1

Hello,
First of all, i have to say my English is really bad. I hope you understand what i said.

Indent guides not working correctly in php files when “tab_size” settings is set to 5.
If i set “tab_size” to 4, or another number except 5, is working correctly.

My Sublime Settings: (Sublime Text 3176)

"translate_tabs_to_spaces": true,
"tab_size": 5,

Screenshot (Not Saved File)
http://forum.sublimetext.com//uploads/default/original/3X/d/b/db6d5042fcc165dddf3fcbb9d62195be683bd24f.PNG

Screenshot (When i save file and REOPEN same file)
http://forum.sublimetext.com/uploads/default/original/3X/3/1/3121e4c677b30fee4664e49754130f25337093ae.PNG

This error only occurs in php files when tab_size is set to 5.

0 Likes

#2

Sublime Text tries to detect the tab_size if a file is opened. This behavior is controlled by the detect_indentation setting.

To detect the indention the first lines of code are parsed to guess the desired tab_size.

Looks like the algorithm gets confused due to the comments, which add an extra space after the first line. It is interpreted as part of the indention resulting in 2 as this is minimal common number of leading spaces of the parsed lines.

Modifying the comments to start with // solves the issue (just for testing).

<?php
     //
     // { item_description }
     //
     abstract class test extends test_extends implement test_interface
     {
          //
          // { item_description }
          //
          protected &test_url = 'http://something'
     }
?>

This issue is therefore not related to the syntax “php” but the style of content.

If all your php files use 5 spaces, you could setup syntax specific settings with:

    "detect_indentation": false,
    "tab_size": 5
2 Likes

#3
"detect_indentation": false,

Its worked. Thank you so much.

0 Likes