VSCode Ctrl+/ will not comment out code file with mixed language as in a PHP file (HTML & PHP)

32 Views Asked by At

[VS code screen showing diffenrent code commenting results applied to HTML and PHP sections

From the above screenshot, after selecting code and pressing Ctrl+/ , you can see the results of attempting to block-comment a piece of code in a PHP file. First off, the commenting tags are of the HTML type (pointed at with the yellow arrows). Note that all the HTML code gets commented out (colored green) while the interspersed PHP code (enclosed in drawn-in red lines) remains uncommented. My first question: is this expected behaviour in VS Code? The second question is, how best to handle commenting in this situation?

I have checked my "settings.json" file ... and reset it completely (ie: wiped out contents and started fresh). I've gone as far as un-installing and re-installing VS Code. Still the same behavior for Ctrl+/ in PHP files. My workaround, for now, is to manually use C-type commenting tags (ie: /* */). If the code I wish to comment out starts with a PHP opening tag (<?php ), I have to insert the opening comment tag right after the "?" symbol as in: <?**/***php ... then it's simple enough to insert the closing C-type comment tag later in any part of the code. Seems Ctrl+/ is not up to automating this specific situation ... Unless someone knows of a special key binding that can handle such a situation. Thanks in advance for your constructive advice.

0

There are 0 best solutions below