Sublime Forum

Escaping nested comments when toggling comment blocks?

#1

For languages that don’t support nested comments, the otherwise excellent “Toggle block comment” command is a bit frustrating, as any existing comment blocks inside of the section you want to comment out will break the new comment. Or just the closing comment character sequence being present e.g. in a string. Example:

/*
function myFunction() {
    const myGlob = 'src/**/*.js'; // <-- outer comment breaks here
    /* And here... */
}
*/

I wonder if anyone has come up with a way to automatically escape/unescaping nested comments? E.g. in Javascript */ would need to be replace with */ or similar, and then converted back when you untoggle the outer comment.

0 Likes

#2

This is for HTML, but seems to be in line with what you’re looking for, and honestly, pretty easy to implement: HTML Nest Comments

0 Likes