PhpStorm:在if/else周围添加空白行 [英] PhpStorm: Add blank lines around if/else

查看:389
本文介绍了PhpStorm:在if/else周围添加空白行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过以下方式配置PhpStorm:

I would like to configure PhpStorm this way:

If/Else PHP代码块应该用空白行分隔.

If/ElseBlocks in PHP code should be separated with a blank line.

示例:

<?php
$hello = true;
if($hello) {
echo "Hello";
} else {
echo "Bye";
}
echo "...my friend";
?>

应该成为

<?php
$hello = true;

if($hello) {
echo "Hello";
} else {
echo "Bye";
}

echo "...my friend";
?>

在JetBrains文档中找不到有关此信息的任何信息.

I did not find any information about that in the JetBrains documentation.

有什么想法可以使它正常工作吗?

Any idea how to get this working?

推荐答案

可能的解决方案:转到文件">设置">编辑器">活动模板";将显示语言列表-选择"PHP",然后单击右侧的加号;在那里您可以创建一个模板,如

Possible solution: go to File>Settings>Editor>Live Templates; there will be a list of languages - select 'PHP', then click plus on the right; there you can create a template like

if(){
echo '';
} else {
echo '';
}

(将保留换行符),然后为模板写一个缩写,并为"PHP"定义上下文. 然后,您可以编写此模板的缩写,然后按 Tab 将其插入任何PHP文件中.

(line breaks will be preserved), then write an abbreviation for the template and define context to 'PHP'. Then you can write the abbreviation of this template and press Tab to insert it in any PHP file.

这篇关于PhpStorm:在if/else周围添加空白行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆