简体   繁体   English

配置IntelliJ以注释单行PHP块

[英]Configure IntelliJ to comment single line PHP blocks

I find IntelliJ is usually great at commenting out code when I highlight it and press Ctrl + / . 我发现IntelliJ通常在突出显示代码并按Ctrl + /时非常擅长注释掉代码。 It handles commenting Java, Scala, Groovy, HTML, Javascript, Typescript, JSPs, JSFs and GSPs perfectly. 它可以完美地处理Java,Scala,Groovy,HTML,Javascript,Typescript,JSP,JSF和GSP的注释。

I am now trying to use it to edit Drupal's PHP files, which are full of single line PHP blocks. 我现在正试图用它来编辑Drupal的PHP文件,这些文件充满了单行 PHP块。 The following is an example. 以下是一个示例。 Pressing Ctrl + / on the following line: 在下一行按Ctrl + /

<?php print render($content['body']); ?>

produces: 生产:

//<?php print render($content['body']); ?>

Can IntelliJ be configured to comment out these single line blocks correctly? 可以将IntelliJ配置为正确注释掉这些单行块吗? Maybe to something like this: 也许是这样的:

<?php /*print render($content['field_date']);*/ ?>

I am using the Ultimate Edition version 12. 我正在使用Ultimate Edition版本12。

Intellij in not designed for working with PHP. Intellij不是为使用PHP而设计的。 I don't think you can configure how comments are applied. 我认为您无法配置如何应用注释。

Two ideas from me: 我的两个想法:

  • go for PHPStorm , JetBrains IDE for PHP, and after pressing Ctrl + / you'll get: 转到PHPStorm ,为PHP使用JetBrains IDE,然后按Ctrl + /后 ,将得到:

    <!-- --> <?php // print render($content['body']); ?>

  • if you want to stick with Intellij, hit Ctrl + W one or more times inside <?php ?> tags; 如果您想使用Intellij,请在<?php ?>标记内按Ctrl + W一次或多次; this will let you select all the contents quickly and then comment them out using Ctrl + Shift + / 这样您就可以快速选择所有内容,然后使用Ctrl + Shift + /对其进行注释

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM