简体   繁体   中英

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 + / . It handles commenting Java, Scala, Groovy, HTML, Javascript, Typescript, JSPs, JSFs and GSPs perfectly.

I am now trying to use it to edit Drupal's PHP files, which are full of single line PHP blocks. The following is an example. Pressing Ctrl + / on the following line:

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

produces:

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

Can IntelliJ be configured to comment out these single line blocks correctly? Maybe to something like this:

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

I am using the Ultimate Edition version 12.

Intellij in not designed for working with 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:

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

  • if you want to stick with Intellij, hit Ctrl + W one or more times inside <?php ?> tags; this will let you select all the contents quickly and then comment them out using Ctrl + Shift + /

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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