Textmate:自动缩进PHP代码的长行

Textmate:自动缩进PHP代码的长行,php,textmate,Php,Textmate,在Textmate中,我可能有一行很长的PHP代码,由于我的窗口宽度,它将被包装成2+行: echo 'This may be a long line of code, which will wrap to multiple lines depending on the width of the browser window...'; 我注意到,将/添加到行的末尾将使它自动缩进第一行下面的任何多行,这样看起来就更好了 echo 'This may be a long line of code,

在Textmate中,我可能有一行很长的PHP代码,由于我的窗口宽度,它将被包装成2+行:

echo 'This may be a long line of code, which will wrap to multiple lines depending on the width of the browser window...';
我注意到,将
/
添加到行的末尾将使它自动缩进第一行下面的任何多行,这样看起来就更好了

echo 'This may be a long line of code, which will wrap to multiple
    lines depending on the width of the browser window...'; //

如何使此行为自动进行(不必在我编写的几乎每行代码的末尾都添加
/
),以及如何将相同的格式添加到其他代码库,如HTML、CSS和SQL?

是否可以尝试查看->软换行或查看->换行列

您应该尽量不要在代码中使用超长字符串,因为这会使其他人难以阅读(尤其是那些将显示器放置90度的人)。很多时候,如果我必须在PHP中使用这样的超长字符串,我会这样做:

echo 'This may be a long line of code, which will wrap to multiple '
     . 'lines depending on the width of the browser window...';
如果出于某种原因需要将一组文本放入变量中,比如原始SQL查询:

$query = 'SELECT id, name, other_column, this_property, something_else '
       . 'FROM really_long_table_name_for_no_reason '
       . 'WHERE other_column IN ['item1', 'item2', 'item3', 'item4'] '
       . 'AND this_property = 7 '
       . 'AND something_else = 'nine_why_not' '
       . 'ORDER BY id DESC LIMIT 30,90';