문제

If I have some JavaScript code that I want to comment out like:

{
    // Inside some scope
    var foo = "bar";
    foo += "bar";
}

I expect to have the following after commenting out the code

{
    /*
    // Inside some scope
    var foo = "bar";
    foo += "bar";
    */
}

But, instead I'll get something like the following, which I have to reindent:

{
    /*
    // Inside some scope
    var foo = "bar";
    foo += "bar";
*/
}

I want to know if there's a preference to prevent this from happening.

도움이 되었습니까?

해결책

Highlight the code you want to comment out, and press ctrl + / - this will comment out the code without any indenting issues and is is easily reversible. The other advantage of this strategy is it works across most languages (including HTML).

Alternatively, you could use ctrl + shift + / to use multiline comments, as rlemon mentions in the comments. (usually I'm too lazy)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top