简体   繁体   中英

How can I prevent sublime text from unindenting after closing a block comment?

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)

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